'image'); protected $_stampFormDefaults = array(); protected $_listOptions = array('defaultOrderBy' => 'sorter'); protected $_actions = array('list', 'cancel', 'new', 'insert', 'edit', 'update', 'delete', 'changeOption', 'reorder', 'updateOrder', 'back', 'deleteRequest', 'createStamp', 'addMark', 'updateMark', 'getMark', 'deleteMark', 'editMark', 'saveMark', 'saveStamp', 'annotation', 'saveAnnotation', 'reportStamp', 'searchPartNumber', 'searchMeltLotNumber', 'autocompleteSerialNumber', 'autocompleteUser'); protected $_messages = array( self::MSG_STAMP_SAVED => 'Chart has been saved', self::MSG_CREATE_STAMP_ERROR => 'Can not create chart', self::MSG_ANNOTATION_CANT_EDIT => 'Annotation can not be edited', self::MSG_ANNOTATION_UPDATED => 'Annotation has been updated', self::MSG_ANNOTATION_ERROR => 'Can not create Annotation', ); protected function _initAction() { $params = $this->getRestParams(); if ($this->getConfig('type') == 'reportStamp') { $this->_defaultAction = 'reportStamp'; } elseif ($this->getConfig('type') == 'stamp') { $this->_defaultAction = 'createStamp'; } elseif (count($params) == 2 && ctype_digit($params[0]) && ctype_digit($params[1])) { $processId = $this->_formDefaults['processId'] = (int) $params[0]; $partId = $this->_formDefaults['partId'] = (int) $params[1]; $process = $this->dataObj->getProcessById($processId); $part = $this->dataObj->getPartById($partId); $departmentId = $process['departmentId']; if ($process && $process['isMedia'] == 'y' && $part && $departmentId && $process['nonUpdateable'] != 'y' && $this->doc->acl->isAllowed($this->doc->getAuthData('id'), $this->dataObj->getDepartmentAliasById($departmentId), App_Acl_Obj::DEPARTMENT_PRIVILEGE)) { $this->dataObj->setProcessId($processId); $this->dataObj->setPartId($partId); $this->dataObj->setFilter(array('processId' => $processId, 'partId' => $partId)); $this->doc->setHeader($process['name'] . ' >> ' . $part['number'] . ' - ' . $part['name']); $this->doc->setTitle($this->doc->getTitle() . ' :: ' . $process['name']); } else { $this->doc->display404(); } $action = Qs_Request::getGetValue('action'); if ($action && $action != 'annotation') { $this->doc->addScript('js/app/mediaEdit.js'); $this->doc->addInitFunction('App_MediaEdit.init', array()); $this->_formDefaults['comments'] = $this->dataObj->getComments(); $this->_formDefaults['versionType'] = App_Part_Obj::REVISION_LOCKED; } } else { $this->doc->display404(); } return parent::_initAction(); } protected function _bindListColumns(Qs_ViewController_List $list) { $list->addColumn('no', 'no', array('orderBy' => 'sorter')); $list->addColumn('annotation', 'image', array('title' => 'Image/Video')); $list->addColumn('title', 'title'); $list->addColumn('type', 'type', array('orderBy' => 'type')); $list->addColumn('downloadLink', 'annotation', array('title' => 'Download')); $list->addColumn('options', 'options', array( 'actions' => array( 'edit' => array(), 'deleteRequest' => array('title' => 'Delete'), 'annotation' => array('title' => 'Annotation') ) )); return $this; } protected function _bindFormFields(Qs_Form $form) { $form->addElement('hidden', 'processId', array('value' => $this->_formDefaults['processId'])); $form->addElement('hidden', 'partId', array('value' => $this->_formDefaults['partId'])); $form->addElement('htmlEditor', 'description', array('required' => false, 'label' => 'Description', 'toolbarSet' => 'Basic')); $form->addElement( 'radio', 'type', array( 'required' => true, 'label' => 'Type', 'multioptions' => array('image' => 'Image', 'video' => 'Video'), 'columns' => 2, 'value' => $this->_formDefaults['type'] ) ); $form->addElement( 'extendedImage', 'image', array( 'label' => 'Image', 'required' => true, 'resize' => array( 'width' => 584, 'height' => 385, 'method' => 'inner', 'quality' => 94, ), ) ); $form->addElement('extendedFile', 'video', array('label' => 'Video', 'description' => 'NOTE: File type must be in FLV format')); $form->video->addValidator('Extension', false, 'flv'); $type = $this->_getData('type'); if ($type != 'image') { $form->video->setRequired(); } $partObj = new App_Part_Obj(array('primaryKey' => $this->dataObj->getPartId())); $this->doc->addScript('js/app/part.js'); $this->doc->addInitFunction('App_Part_Administration.init', array(array('formSelector' => '#process_media-form'))); App_Part_View::appendAdministrativeOptions($form, $this->_doc, $partObj->getData('revisionStatus'), $partObj->getData('blockedUser'), in_array($this->_action, array('update', 'insert'))); $form->addElement('static', 'partVersionLocked', array('value' =>'')); $form->addFormRule(array($this, 'validateForm')); return $this; } public function validateForm($data) { $partObj = new App_Part_Obj(array('primaryKey' => $this->dataObj->getPartId())); $errors = App_Part_View::validateRevision($partObj->getData(), $data); if (isset($errors['versionLocked'])) { $errors['partVersionLocked'] = $errors['versionLocked']; } return (empty($errors)) ? true : $errors; } protected function _renderMainForm(Qs_Form $form) { $form->getDecorator('HtmlTag')->setOption('class', $form->type->getValue()); return parent::_renderMainForm($form); } protected function _doDelete() { $form = $this->_getDeleteForm(); if ($form->validate()) { $this->_initFromForm($form); parent::_doDelete(); } else { parent::_renderMainForm($form); } return $this; } protected function _doDeleteRequest() { $form = $this->_getDeleteForm(); $form->setDefaults(array('versionType' => App_Part_Obj::REVISION_LOCKED)); parent::_renderMainForm($form); return $this; } protected function _getDeleteForm() { $form = $this->_getBaseForm(); $form->addElement('hidden', 'action', array('value' => 'delete')); $form->addElement('hidden', 'id', array('value' => $this->dataObj->getPrimaryKey())); $partObj = new App_Part_Obj(array('primaryKey' => $this->dataObj->getPartId())); $this->doc->addScript('js/app/part.js'); $this->doc->addInitFunction('App_Part_Administration.init', array(array('formSelector' => '#process_media-form'))); App_Part_View::appendAdministrativeOptions($form, $this->_doc, $partObj->getData('revisionStatus'), $partObj->getData('blockedUser'), true); $this->_bindFormButtons($form); return $form; } protected function _doDeleteAjax() { $form = $this->_getDeleteForm(); $this->_validateAjax($form); } /** * Create/Edit stamp * create url: $mediaId * edit url: $mediaId/$stampId * @param null $form */ protected function _doCreateStamp($form = null) { $this->_setBackUrl($this->_getBackUrl(CURRENT_PAGE_FINAL)); $params = $this->getRestParams(); $paramCount = count($params); if (($paramCount == 1 || $paramCount == 2) && ctype_digit($params[0])) { $mediaId = $params[0]; $obj = $this->_getDataObj(); $obj->setPrimaryKey($mediaId); if (null == $obj->getData()) { $this->_doc->display404(); } // edit stamp $stamp = null; $stampObj = $this->_getStampObj(); if ($paramCount == 2) { if (!ctype_digit($params[1]) || !($stamp = $stampObj->setPrimaryKey($params[1])->getData())) { $this->_doc->display404(); } $obj->setStampId($stamp['stampId']); $this->_stampFormDefaults = $stamp; $obj->readMarks(); } $this->doc->addStylesheet('css/jquery.fancybox-1.3.4.css'); $this->doc->addStylesheet('css/jquery-ui.css'); $this->doc->addStylesheet('css/formBuilder.css'); $this->doc->addScript('js/lib/form.js'); $this->doc->addScript('js/jquery.scrollTo.js'); $this->doc->addScript('js/jquery-ui.js'); $this->doc->addScript('js/jquery.form.js'); $this->doc->addScript('js/jquery.fancybox-1.3.4.js'); $this->doc->addScript('js/app/weldingStamp.js'); $this->doc->addScript('js/app/weldingStampMark.js'); $this->_addColorPickerScripts(); $item = array( 'marks' => array(), 'tpl' => $this->getTemplate('createStamp.tpl'), 'image' => Qs_ImageFs::getFullAttribs($this->_getData('image')) ); // method should be called before form are created, so form get use _getData() $formDefaults = $this->_getStampFormDefaults(); if (null === $form) { $form = $this->_getCreateStampForm(); } $form->setDefaults($formDefaults); $form->initRender(); $form->removeContainers(); $item['form'] = $form; $stampOptions = array( 'marks' => array(), 'id' => $this->dataObj->getStampId(), 'callbackUrl' => BASE_URL . '/' . CURRENT_PAGE, ); foreach ($this->dataObj->getMarks() as $mark) { $stampOptions['marks'][] = array('id' => $mark['id']); $markItem = new Qs_Doc_Item($this->getItem($mark)); $item['marks'][] = $markItem; } $this->_doc->addInitObject( 'Qs_WeldingStamp', array($stampOptions), 'weldingStamp' ); $this->doc->addStylesheet(BASE_URL . '/' . 'css/font-awesome.min.css'); $this->doc->addItem($item); } else { $this->_setBackMessage($this->_messages[self::MSG_CREATE_STAMP_ERROR]); $this->_doBack(); } } protected function _getStampFormDefaults($field = null) { if (empty($this->_stampFormDefaults['__defaultsInitialized'])) { $this->_stampFormDefaults['__defaultsInitialized'] = true; $defaults = array( 'htCondition' => 'ascast', 'quantity' => '1', ); $auth = App_User_Auth::getInstance(); if ($auth->isLoggedIn() && ($userId = $auth->getData('id'))) { $defaults['personWelding'] = $userId; } $this->_stampFormDefaults = array_merge($defaults, $this->_stampFormDefaults); $this->_stampFormDefaults['action'] = 'saveStamp'; $this->_stampFormDefaults['mediaId'] = $this->dataObj->getPrimaryKey(); $this->_stampFormDefaults['id'] = $this->dataObj->getStampId(); $this->_stampFormDefaults['stampId'] = $this->dataObj->getStampId(); } return Qs_Array::get($this->_stampFormDefaults, $field); } protected function _getStampData($field = false, $default = null, $method = 'POST') { $result = null; if ($_SERVER['REQUEST_METHOD'] == strtoupper($method)) { $result = (false === $field) ? $_POST : Qs_Request::getPostValue($field); } if (null === $result) { $result = $this->_getStampFormDefaults($field); } return (null === $result) ? $default : $result; } protected function _doSaveStampAjax() { $form = $this->_getCreateStampForm(); $this->_validateAjax($form); } protected function _doSaveStamp() { // edit stamp, set stamp primary key $params = $this->getRestParams(); if (count($params) == 2) { if (!ctype_digit($params[1]) || !($this->_getStampObj()->setPrimaryKey($params[1])->getData())) { $this->_doc->display404(); } } $form = $this->_getCreateStampForm(); if ($form->validate()) { $data = $form->getValues(); $this->dataObj->initFromForm($data); $this->dataObj->setStampId($data['id']); $this->dataObj->saveStamp(); $this->_setBackMessage($this->_messages[self::MSG_STAMP_SAVED]); } else { $this->_doCreateStamp($form); } $this->_doBack(); } protected function _getCreateStampForm() { $form = $this->_getBaseForm(); $form->addElement('text', 'stampId', array('label' => 'Chart ID', 'required' => true)); $form->addElement('text', 'meltLotNumber', array('label' => 'Melt Lot Number', 'required' => true)); $form->addElement('text', 'serialNumber', array('label' => 'Serial Number ', 'required' => true)); $form->addElement('text', 'htCondition', array('label' => 'HT condition', 'required' => true)); $form->addElement('text', 'welderId', array('label' => 'Weld Machine', 'required' => true)); $userAutocompleteUrl = BASE_URL . '/' . CURRENT_PAGE . '?' . http_build_query(array('action' => 'autocompleteUser')); $form->addElement('autocomplete', 'personWelding', array( 'label' => 'Charter', 'size' => 30, 'notFoundMessage' => 'Person "%value%" was not found in the system', 'url' => $userAutocompleteUrl, 'filters' => array(new Zend_Filter_StringTrim()), ) ); /** @var Qs_Form_Element_Autocomplete $personWeldingElement */ $personWeldingElement = $form->getElement('personWelding'); if (($userId = $this->_getStampData('personWelding')) && ($userName = $this->_getStampObj()->getUserName($userId))) { $personWeldingElement->setMultiOptions(array($userId => $userName)); } $form->addElement('text', 'weldRodLotNo', array('label' => 'Weld Rod Lot #', 'maxlength' => 50, 'required' => false)); $form->addElement('text', 'timeCardLine', array('label' => 'Reject Tag Time Card Info', 'required' => false)); $form->addElement('text', 'quantity', array('label' => 'Quantity', 'required' => false)); $form->getElement('quantity')->addValidator('Float'); $form->getElement('quantity')->addValidator('Between', false, array('min' => '0', 'max' => 99999.999)); $form->addElement('hidden', 'mediaId'); $form->addElement('hidden', 'id'); $form->addElement('hidden', 'action'); $stampValidator = new Qs_Validate_Unique($this->dataObj->tableStamp, 'stampId', $this->_getStampFormDefaults('id')); $stampValidator->setMessage('Chart ID must be unique', Qs_Validate_Unique::NOT_UNIQUE); $form->stampId->addValidator($stampValidator); $this->_bindFormButtons($form); return $form; } protected function _doAddMarkAjax() { $this->dataObj->setStampId(Qs_Request::getGetValue('id')); $mark = $this->dataObj->addMark(Qs_Request::getGetValue('mark')); $this->_addItem($this->getItem($mark)); $this->_displayResult(array('id' => $mark['id'])); } protected function _doUpdateMarkAjax() { $this->dataObj->setStampId(Qs_Request::getGetValue('id')); $mark = $this->dataObj->updateMark(Qs_Request::getGetValue('markId'), Qs_Request::getGetValue('mark')); $this->_addItem($this->getItem($mark)); $this->_displayResult(); } public function getItem($mark) { return array( 'tpl' => $this->getTemplate('viewMark.tpl'), 'id' => $this->dataObj->getStampId(), 'mark' => $mark, 'markId' => $mark['id'] ); } protected function _doGetMarkAjax() { $this->dataObj->setStampId(Qs_Request::getGetValue('id')); $mark = $this->dataObj->getMark(Qs_Request::getGetValue('markId')); $this->_addItem($this->getItem($mark)); $this->_displayResult(); } protected function _doDeleteMarkAjax() { $this->dataObj->setStampId(Qs_Request::getGetValue('id')); $this->dataObj->deleteMark(Qs_Request::getGetValue('markId')); $this->_displayJson(array('result' => true)); } protected function _doEditMarkAjax() { $this->dataObj->setStampId(Qs_Request::getGetValue('id')); $form = $this->_getEditMarkForm(); $defaults = $this->dataObj->getMark(Qs_Request::getGetValue('markId')); $defaults['action'] = 'saveMark'; $defaults['id'] = $this->dataObj->getStampId(); $defaults['markId'] = Qs_Request::getGetValue('markId'); $form->setDefaults($defaults); $this->doc->setTemplatePath(array('SpeedyDoc', 'Doc')); $this->_renderForm($form, 'propertyForm.tpl'); } protected function _getEditMarkForm() { $formOptions = $this->_getBaseFormOptions(); $formOptions['attribs']['id'] = 'stamp-mark-form'; $form = new Qs_Form($formOptions); $form->addElement('hidden', 'id'); $form->addElement('hidden', 'markId'); $form->addElement('hidden', 'action'); $form->addElement('select', 'type', array('label' => 'Mark Type', 'required' => true, 'multiOptions' => array( 'circle-o' => 'Empty Circle', 'check' => 'Check', 'bolt' => 'Bolt', 'circle' => 'Circle', 'asterisk' => 'Asterisk', 'close' => 'Cross', 'crosshairs' => 'CrossHair', ))); $form->addElement('select', 'size', array('label' => 'Mark Size', 'required' => true, 'multiOptions' => array( 's' => 'S', 'lg' => 'M', '2x' => 'L', '3x' => 'XL', '4x' => 'XXL', ))); $form->addElement('colorPicker', 'color', array('label' => 'Mark Color', 'required' => true)); $form->addElement( 'select', 'scrapCode', array( 'label' => 'Scrap Code', 'required' => true, 'multiOptions' => array('' => 'Select One') + $this->dataObj->getScrapCodes() ) ); $form->addElement('text', 'length', array('label' => 'Length', 'required' => true, 'validators' => array('Float'))); $form->length->addValidator('LessThan', false, array('max' => 99999.999)); $form->addElement('text', 'width', array('label' => 'Width', 'required' => true, 'validators' => array('Float'))); $form->width->addValidator('LessThan', false, array('max' => 99999.999)); $form->addElement('text', 'depth', array('label' => 'Depth', 'required' => true, 'validators' => array('Float'))); $form->depth->addValidator('LessThan', false, array('max' => 99999.999)); $form->addElement('text', 'disposition', array('label' => 'Disposition', 'required' => true)); $form->addElement('checkbox', 'badWeld', array('label' => 'Bad Weld', array( 'label' => 'Disposition', 'decoration' => 'simple', 'checkedValue' => 'y', 'uncheckedValue' => 'n') )); $form->addElement('textarea', 'comments', array('label' => 'Comments', 'rows' => 3, 'cols' => 40, 'required' => false)); $form->addElement('submit', 'btnSubmit', array( 'label' => 'Save', 'attribs' => array('class' => 'btn'), 'decorators' => array('ViewHelper')) ); $form->addElement('button', 'btnCancel', array( 'label' => 'Cancel', 'attribs' => array('class' => 'btn', 'onclick' => '$.fancybox.close();'), 'decorators' => array('ViewHelper')) ); $decorators = array( 'FormElements', array('decorator' => 'HtmlTag', 'options' => array('tag' => 'div')), 'Fieldset', 'DtDdWrapper'); $form->addDisplayGroup(array('btnSubmit', 'btnCancel'), 'submitGroup', array('decorators' => $decorators)); return $form; } protected function _doSaveMarkAjax() { $form = $this->_getEditMarkForm(); $result = $this->_getValidateAjaxResult($form); if ($result['isValid']) { $data = $form->getValues(); unset($data['action']); $this->dataObj->setStampId($data['id']); $data['id'] = $data['markId']; unset($data['markId']); $this->dataObj->updateMark($data['id'], $data); } $this->_displayResult($result); } protected function _displayResult($result = array()) { $this->doc->setTemplatePath(array('SpeedyDoc', 'Doc')); $result['html'] = $this->doc->fetch(); $this->_displayJson($result); } public function fillConfigForm(Qs_Form $form) { $form->addElement( 'select', 'type', array( 'label' => 'Block Type', 'multiOptions' => array( 'default' => 'Default', 'stamp' => 'Chart', ) ) ); return $this; } protected function _addColorPickerScripts() { $this->doc->addStylesheet('css/jquery-ui.css'); $this->doc->addScript('js/jquery-ui.js'); $this->doc->addStylesheet('css/colorpicker/jquery.colorpicker.css'); $this->doc->addScript('js/colorpicker/jquery.colorpicker.js'); $this->doc->addScript('js/colorpicker/i18n/jquery.ui.colorpicker-en.js'); $this->doc->addScript('js/colorpicker/swatches/jquery.ui.colorpicker-pantone.js'); $this->doc->addScript('js/colorpicker/parts/jquery.ui.colorpicker-rgbslider.js'); $this->doc->addScript('js/colorpicker/parts/jquery.ui.colorpicker-memory.js'); $this->doc->addScript('js/colorpicker/parsers/jquery.ui.colorpicker-cmyk-parser.js'); $this->doc->addScript('js/colorpicker/parsers/jquery.ui.colorpicker-cmyk-percentage-parser.js'); $this->doc->addScript('js/lib/form-element-colorPicker.js'); } protected function _doAnnotation($form = null) { $form = $this->getAnnotationForm(); $this->dataObj->initData(); $data = $this->_getData4Form(); if ($data['type'] == App_Process_Media_AbstractObj::TYPE_IMAGE) { $defaults = array( 'svgAnnotation' => $data['image'], 'versionType' => App_Part_Obj::REVISION_LOCKED, 'comments' => $data['comments'] ); $form->setDefaults($defaults); parent::_renderMainForm($form); } return $this; } /** * @return Qs_Form */ public function getAnnotationForm() { $form = $this->_getBaseForm(); $this->_bindAnnotationFormFields($form); $this->_bindFormButtons($form); $form->addElement('hidden', 'action', array('value' => 'saveAnnotation')); if (null !== ($primaryKey = $this->getPrimaryKey())) { if (is_array($primaryKey) && !empty($primaryKey)) { foreach ($primaryKey as $name => $value) { $form->addElement('hidden', $name, array('value' => $value)); } } } return $form; } protected function _bindAnnotationFormFields(Qs_Form $form) { $data = $this->_getData4Form(); $currentRevision = App_Process_Media_Obj::getLastAnnotationRevision($data['image'], $this->dataObj->getUserCurrentRevision()); $form->addElement( 'svgEditor', 'svgAnnotation', array( 'required' => false, 'label' => 'Annotation', 'revision' => $currentRevision ) ); $this->doc->addScript('js/app/part.js'); $this->doc->addInitFunction( 'App_Part_Administration.init', array(array('formSelector' => '#process_media-form')) ); $partObj = new App_Part_Obj(array('primaryKey' => $this->dataObj->getPartId())); App_Part_View::appendAdministrativeOptions($form, $this->_doc, $partObj->getData('revisionStatus'), $partObj->getData('blockedUser'), false); return $this; } protected function _doSaveAnnotationAjax() { $form = $this->getAnnotationForm(); $this->_validateAjax($form); } protected function _doSaveAnnotation() { $form = $this->getAnnotationForm(); $data = $this->_getData('svgAnnotation'); if ($form->validate() && $this->validateAnnotation($data)) { if ($this->_updateRevision() && $this->saveSvgFile($data, $this->dataObj->getAnnotationRevision())) { $this->_setBackMessage($this->_messages[self::MSG_ANNOTATION_UPDATED]); } else { $this->_setBackMessage($this->_messages[self::MSG_ANNOTATION_ERROR]); } $this->_doBack(); } else { $this->_doBack(); } return $this; } protected function _updateRevision() { $mediaData = $this->dataObj->setPrimaryKey($this->_getData('id'))->getData(); $mediaData['versionType'] = $this->_getData('versionType'); $mediaData['comments'] = $this->_getData('comments'); return $this->dataObj->update($mediaData); } public static function validateAnnotation($data) { if ($data['bgFile'] && $data['svgData'] && file_exists(WWW_PATH . '/' . Qs_ImageFs::WEB_PATH . '/' . $data['bgFile']) ) { return true; } return false; } public static function saveSvgFile($data, $revision) { if (null === $revision) { return false; } $revisionSuffix = ($revision > 0) ? '_rev_' . $revision : ''; $destinationPath = WWW_PATH . '/' . Qs_ImageFs::WEB_PATH . '/'; $svg_filename = pathinfo($data['bgFile'], PATHINFO_FILENAME) . $revisionSuffix . '.svg'; $filePath = $destinationPath . $svg_filename; if (is_writable($destinationPath)) { if (!$fp = fopen($filePath, 'w+')) { return false; } if (fwrite($fp, base64_decode($data['svgData'])) === false) { return false; } fclose($fp); } else { return false; } return true; } protected function _getStampObj() { return $this->_getDataObj()->getStampObj(); } protected function _doReportStamp() { $this->_doc->setTitle('Weld Chart Report'); $this->_doc->setHeader('Weld Chart Report'); if ('print' === ($mode = Qs_Request::getGetValue('mode'))) { // generate print-friendly version of report $this->_generatePrintableReportStamp(); return $this; } $this->_addFilterStampItem(); $filter = array_filter($this->_getStampObj()->getFilter()); if ($filter && null == $this->_getStampObj()->getListSelect()->query()->fetch()) { $item = array( 'tpl' => $this->getTemplate('text.tpl'), 'text' => 'No Results', ); $this->_addItem($item); return $this; } if ($filter) { // generate pdf from url using wkhtml2pdf $this->_renderReportStampPdf(); } return $this; } protected function _renderReportStampPdf() { $obj = $this->_getStampObj(); if (null == ($filter = array_filter($obj->getFilter()))) { exit; } $options = (array) Qs_Request::getGet(); $options['mode'] = 'print'; $reportUrl = $this->url($options); $nameParts = array(); $headerParts = array(); $form = $this->_getStampFilterForm(); foreach ($filter as $name => $value) { if (($element = $form->getElement($name))) { $label = $element->getLabel(); if ($value && ($name === 'fromDate' || $name === 'toDate')) { $value = strftime('%m/%d/%Y', strtotime($value)); } $nameParts[] = $label . '-' . $value; $headerParts[] = $label . ': ' . $value; } } $pdfName = 'Weld-Chart-Report-' . implode(',', $nameParts) . '.pdf'; $pageHeader = 'Weld Chart Report (' . implode(', ', $headerParts) . ')'; try { $rendererOptions = array( 'pageHeader' => $pageHeader, 'params' => array('--footer-center "[page]"'), ); if (($file = App_Pdf_Renderer::render($reportUrl, $pdfName, $rendererOptions))) { App_Pdf_Renderer::sendTempFile($file, $pdfName); } } catch (App_Part_Export_NotMovedException $e) { exit($e->createMessage()); } catch (Exception $e) { exit('Error: File "' . basename($pdfName) . '" failed to export. ' . PHP_EOL . $e); } exit; } protected function _generatePrintableReportStamp() { $this->_doc->setTemplatePath(array('PrintDoc', 'Doc')); $form = $this->_getStampFilterForm(); if ($form->validate()) { $this->_getStampObj()->addFilter($form->getValues()); } if (array_filter($this->_getStampObj()->getFilter())) { $this->_addStampListItem(); } return $this; } protected function _addFilterStampItem() { $form = $this->_getStampFilterForm(); if ($form->validate()) { $this->_getStampObj()->addFilter($form->getValues()); } $this->_renderForm($form, Qs_Constant::get(array($this, 'FILTER_TEMPLATE'))); } protected function _getStampFilterForm() { $form = $this->_getBaseForm(); $form->setAjaxValidation(false)->setMethod('get') ->setAttrib('id', 'report-stamp-filter-form') ->setAttrib('class', 'filter_form report_stamp_filter_form'); $partNumberUrl = BASE_URL . '/' . CURRENT_PAGE . '?' . http_build_query(array('action' => 'searchPartNumber')); $form->addElement('autocomplete', 'partNumber', array( 'label' => 'Part Number', 'size' => 30, 'notFoundMessage' => 'Part Number "%value%" was not found', 'url' => $partNumberUrl, 'filters' => array(new Zend_Filter_StringTrim()), ) ); $meltLotNumberUrl = BASE_URL . '/' . CURRENT_PAGE . '?' . http_build_query(array('action' => 'searchMeltLotNumber')); $form->addElement('autocomplete', 'meltLotNumber', array( 'label' => 'Melt Lot Number', 'size' => 30, 'notFoundMessage' => 'Melt Lot Number "%value%" was not found', 'url' => $meltLotNumberUrl , 'filters' => array(new Zend_Filter_StringTrim()), ) ); $serialNumberAutocompleteUrl = BASE_URL . '/' . CURRENT_PAGE . '?' . http_build_query(array('action' => 'autocompleteSerialNumber')); $form->addElement('autocomplete', 'serialNumber', array( 'label' => 'Serial Number', 'size' => 30, 'notFoundMessage' => 'Serial Number "%value%" was not found', 'url' => $serialNumberAutocompleteUrl , 'filters' => array(new Zend_Filter_StringTrim()), ) ); $form->addElement('date', 'fromDate', array( 'label' => 'From Date', ) ); $form->addElement('date', 'toDate', array( 'label' => 'To Date', ) ); $form->addElement( 'submit', 'btnSearch', array( 'label' => 'Render PDF', 'ignore' => true, 'attribs' => array('class' => 'btn'), 'decorators' => array('ViewHelper') ) ); $form->addElement( 'button', 'btnCancel', array( 'label' => 'Reset', 'ignore' => true, 'decorators' => array('ViewHelper'), 'attribs' => array( 'class' => 'btn', 'onclick' => "document.location='" . BASE_URL . '/' . CURRENT_PAGE . "';", ) ) ); $decorators = array('FormElements'); $decorators[] = array('decorator' => 'HtmlTag', 'options' => array('tag' => 'dl')); $decorators[] = 'Fieldset'; $form->addDisplayGroup(array('btnSearch', 'btnCancel'), 'submitGroup', array('decorators' => $decorators)); return $form; } protected function _doSearchPartNumberAjax() { $this->_displayJson($this->_getStampObj()->getPartNumbers(Qs_Request::getGetValue('q'))); } protected function _doSearchMeltLotNumberAjax() { $this->_displayJson($this->_getStampObj()->getMeltLotNumbers(Qs_Request::getGetValue('q'))); } protected function _doAutocompleteSerialNumberAjax() { $this->_displayJson($this->_getStampObj()->getSerialNumbers4Autocomplete(Qs_Request::getGetValue('q'))); } protected function _doAutocompleteUser() { exit; } protected function _doAutocompleteUserAjax() { $this->_displayJson($this->_getStampObj()->getUsers4Autocomplete(Qs_Request::getGetValue('q'))); } protected function _addStampListItem() { $item = array( 'tpl' => $this->getTemplate('stampReport.tpl'), 'list' => $this->_getStampObj()->getList() ); $this->doc->addStylesheet(BASE_URL . '/' . 'css/font-awesome.min.css'); $this->_addItem($item); return $this; } public static function getReportStampPageUrl(array $options = null) { return BASE_URL . '/' . Qs_SiteMap::findFirst(null, array('type' => 'Process_Media_'), array('type' => 'reportStamp'), 'fullAlias') . ($options ? '?' . http_build_query($options) : ''); } }