public function printdocumentation()
 {
     $flash = Flash::Instance();
     if (isset($this->_data['cancel'])) {
         $flash->addMessage('Print Works Order Documentation Cancelled');
         sendBack();
     }
     $errors = array();
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $worksorder = $this->_uses[$this->modeltype];
     $data = $this->_data;
     $docs_count = unserialize($worksorder->documentation);
     $merge_file_name = 'mfworksorders_documentation_' . $data['id'] . '_' . date('H_i_s_d_m_Y') . '.pdf';
     // Need to check to see if array count is equal to, or less than 1, and if array element 0 is null
     if (count($docs_count) <= 1 && $docs_count[0] == '') {
         $errors[] = 'No Documents Assigned to Works Order';
     } else {
         if ($worksorder) {
             $documents = InjectorClass::unserialize($worksorder->documentation);
             foreach ($documents as $document) {
                 // when we fire the construct, pass the printController as the report does
                 // not extend another model
                 $model = new $document->class_name($this);
                 $args = array('model' => $worksorder, 'data' => $data, 'merge_file_name' => $merge_file_name);
                 //$response=$model->buildReport($worksorder,$data);
                 $response = $model->buildReport($args);
                 if ($response->status !== true) {
                     $errors[] = $document->class_name . ": " . $response->message;
                 }
             }
         } else {
             $errors[] = 'Failed to find Works Order';
         }
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
     } else {
         // construct file path, print the file and add a success message
         $merge_file_path = $this->get_filetype_path('tmp') . $merge_file_name;
         $this->output_file_to_printer($merge_file_path, $data['printer']);
         $flash->addMessage('Print Works Order Completed');
     }
     sendBack();
 }
Beispiel #2
0
 function getDocumentList()
 {
     return InjectorClass::unserialize($this->documentation);
 }