示例#1
0
	public static function run()
	{
		
		$getPrintQueue = \Printmanager\Model_Printmanager_Queue::query()->where('scheduled', '<=', date('Y-m-d H:m:s'))->where('status', 'WAITING')->get();
		
		foreach ($getPrintQueue AS $printJob)
		{
			$tray = \Printmanager\Model_Printmanager_Tray::find($printJob->tray_id);
			$printer = \Printmanager\Model_Printmanager_Printer::find($tray->printer_id);
			
			\Printmanager\Queue::printItem($printJob->filename, $printer->printer_reference, $tray->tray_name);
			
			$printJob->status = "IN PROGRESS";
			$printJob->save();
			
		}
		
		
	}
示例#2
0
 public function action_print_form($formName = null, $ext = 'pdf')
 {
     $status = null;
     $message = null;
     if (is_null($formName)) {
         $status = 'error';
         $message = 'Form name not given';
     } else {
         $file = DOCROOT . 'uploads/crm/forms/' . $formName . '.' . $ext;
         if (file_exists($file)) {
             \Printmanager\Queue::add($file, (int) date('H') < 14 ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00'), 1);
             $status = 'success';
             $message = 'Form sent to printer queue';
         } else {
             $status = 'error';
             $message = 'Form ' . $file . ' Can not be found';
         }
     }
     $this->response(array('status' => $status, 'message' => $message));
 }
示例#3
0
 /**
  * Process the rreturned pack documents
  * @access public
  * @author David
  */
 public function action_pack_in_check($clientID = 0)
 {
     // -- Get the serialized documents info for checking when packs were chased
     // ------------------------------------------------------------------------
     $savedDocuments = array();
     $ppiClient = \Crm\Ppi\Ppi_class::forge((int) $clientID);
     $savedDocuments = $ppiClient->getPackReturnedDocuments();
     $date = date("d/m/Y");
     $documents = array();
     $documents = array('Creditor Information' => array('Completed' => \Input::post('DOCCHECK_Creditor_Information') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['Creditor Information']['Chase Date']) && $savedDocuments['Creditor Information']['Chase Date'] != '' && \Input::post('DOCCHECK_Creditor_Information') != 'on' ? $savedDocuments['Creditor Information']['Chase Date'] : (\Input::post('DOCCHECK_Creditor_Information') != 'on' ? $date : ''), 'Notes' => ''), 'LOA' => array('Completed' => \Input::post('DOCCHECK_LOA') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['LOA']['Chase Date']) && $savedDocuments['LOA']['Chase Date'] != '' && \Input::post('DOCCHECK_LOA') != 'on' ? $savedDocuments['LOA']['Chase Date'] : (\Input::post('DOCCHECK_LOA') != 'on' ? $date : ''), 'Notes' => ''), 'TaC' => array('Completed' => \Input::post('DOCCHECK_TaC') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['TaC']['Chase Date']) && $savedDocuments['TaC']['Chase Date'] != '' && \Input::post('DOCCHECK_TaC') != 'on' ? $savedDocuments['TaC']['Chase Date'] : (\Input::post('DOCCHECK_TaC') != 'on' ? $date : ''), 'Notes' => ''), 'Section F' => array('Completed' => \Input::post('DOCCHECK_Section_F') == 'on' ? 'Yes' : 'No', 'Chase Date' => isset($savedDocuments['Section F']['Chase Date']) && $savedDocuments['Section F']['Chase Date'] != '' && \Input::post('DOCCHECK_Section_F') != 'on' ? $savedDocuments['Section F']['Chase Date'] : (\Input::post('DOCCHECK_Section_F') != 'on' ? $date : ''), 'Notes' => ''));
     if ($ppiClient->pack_completed == 'no') {
         // -- Only process if the pack isn't completed
         // -------------------------------------------
         // -- Save the document information back
         // -------------------------------------
         $ppiClient->savePackReturnedDocuments($documents);
         $correspondence = \Crm\Ppi\Ppi_correspondence::forge((int) $clientID);
         $correspondenceMsg = null;
         // -- If any of the documents have missing infomation and it isn't currently being chased then send out a letter and paperwork, also add a new correspondence
         // ----------------------------------------------------------------------------------------------------------------------------------------------------------
         if (\Input::post('DOCCHECK_Creditor_Information') == 'on' && \Input::post('DOCCHECK_LOA') == 'on' && \Input::post('DOCCHECK_TaC') == 'on' && \Input::post('DOCCHECK_Section_F') == 'on') {
             // -- All paperwork is now complete
             // --------------------------------
             // 1) Mark the Pack as complete
             // 2) Create a correspondence that the pack is complete
             $ppiClient->setPackCompleted();
             $correspondence->saveNew(0, 2, 5, 0, 'Pack Completed');
         } else {
             $letterHead = array();
             $letterBlank = array();
             $missing = array();
             $referralInfo = \Crm\Referrals\Referrals_class::forge((int) $correspondence->referral_id);
             $creditors = $referralInfo->loadData('creditors');
             $letterConfig = \Crm\Ppi\Ppi_class::loadLettersList((int) $ppiClient->company_id);
             unset($referralInfo);
             // -- Missing Creditor Information
             // -------------------------------
             if (\Input::post('DOCCHECK_Creditor_Information') != 'on' && $savedDocuments['Creditor Information']['Chase Date'] == '') {
                 $correspondenceMsg .= 'Pack Incomplete. Missing information found on the Creditor Information Section.' . "\r\n";
                 $letterHead[] = array('id' => $letterConfig['missing_loa'], 'qty' => 1, 'tray_id' => 2);
                 $letterBlank[] = array('id' => $letterConfig['ppi_form_of_authority'], 'qty' => count($creditors) > 0 ? count($creditors) : 3, 'tray_id' => 1);
                 $missing[] = '<li>Creditor name / Account Number</li>';
             }
             // -- Missing LOA
             // --------------
             if (\Input::post('DOCCHECK_LOA') != 'on' && $savedDocuments['LOA']['Chase Date'] == '') {
                 $correspondenceMsg .= 'Pack Incomplete. Missing information found on the LOA Section.' . "\r\n";
                 $letterHead[] = array('id' => $letterConfig['missing_loa'], 'qty' => 1, 'tray_id' => 2);
                 $letterBlank[] = array('id' => $letterConfig['ppi_form_of_authority'], 'qty' => count($creditors) > 0 ? count($creditors) : 3, 'tray_id' => 1);
                 $missing[] = '<li>Signed Form of Authority</li>';
             }
             // -- Missing Terms and Conditions
             // -------------------------------
             if (\Input::post('DOCCHECK_TaC') != 'on' && $savedDocuments['TaC']['Chase Date'] == '') {
                 $correspondenceMsg .= 'Pack Incomplete. Missing information found on the Terms and Conditions Section.' . "\r\n";
                 $letterHead[] = array('id' => $letterConfig['missing_tac'], 'qty' => 1, 'tray_id' => 2);
                 $letterBlank[] = array('id' => $letterConfig['terms_and_conditions_GAB'], 'qty' => 1, 'tray_id' => 1);
                 $missing[] = '<li>Signed Terms and Conditions</li>';
             }
             // -- Missing Section "F"
             // ----------------------
             if (\Input::post('DOCCHECK_Section_F') != 'on' && $savedDocuments['Section F']['Chase Date'] == '') {
                 $correspondenceMsg .= 'Pack Incomplete. Missing information Section F Isn\'t filled in.' . "\r\n";
                 $missing[] = '<li>Signed Section F</li>';
                 $printSectionF = true;
             }
         }
     }
     if (!is_null($correspondenceMsg)) {
         // -- Pack is found to be incomplete. Set correspondence and send letter out
         // -------------------------------------------------------------------------
         $correspondence->saveNew(0, 2, 2, 0, $correspondenceMsg);
         if ($ppiClient->company_id == 1) {
             $timeSlot = 1;
         } else {
             if ($ppiClient->company_id == 3) {
                 $timeSlot = 2;
             }
         }
         // -- Persolvo Letters
         if (count($missing) > 1) {
             unset($letterHead);
             $letterHead[] = array('id' => $letterConfig['missing_several_documents'], 'qty' => 1, 'tray_id' => 2);
             $extraData = array();
             $freeText = '';
             foreach ($missing as $missingText) {
                 $freeText .= $missingText;
             }
             $extraData = array('freeText' => $freeText);
         }
         #if(count($letterHead) > 0)
         #  \Crm\Letter\Pack::forge((int)$clientID,null,$letterHead)->setOutputFilename('ppi_missing_info_pack_coverletter_' . date("dmy") . '_' .(int)$clientID.'.pdf')->printLetter(2, 40)->timeSlot($timeSlot)->create();
         \Crm\Letter\Letter::forge($clientID, null, $extraData)->writeContent($letterHead[0]['id'])->setOutputFilename('ppi_missing_info_pack_coverletter_' . date("dmy") . '_' . (int) $clientID . '.pdf')->printLetter($letterHead[0]['tray_id'])->timeSlot($timeSlot)->create();
         if (count($letterBlank) > 0) {
             \Crm\Letter\Pack::forge((int) $clientID, null, $letterBlank)->setOutputFilename('ppi_missing_info_pack_' . date("dmy") . '_' . (int) $clientID . '.pdf')->printLetter(1, 40)->timeSlot($timeSlot)->create();
         }
         if ($printSectionF == true) {
             \Printmanager\Queue::add(DOCROOT . 'uploads/crm/forms/section_f_form.pdf', $timeSlot == 1 ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00'), 1);
         }
         #\Printmanager\Queue::add(DOCROOT . 'uploads/crm/forms/section_f_form.pdf', ( (int)date('H') < 14 ) ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00'), 1);
         $correspondence->saveNew(0, 2, 3, 0, 'Letter Sent to Client');
     }
     // -- If all the documents have been completed, then set the Pack Completed field as Yes
     // -------------------------------------------------------------------------------------
     Response::redirect('crm/view_client/' . $clientID . '/');
 }
示例#4
0
 /**
  * Creates a PDF file and stores it.
  * 
  * @access public
  * @return object
  *
  * @author Simon Skinner <*****@*****.**>
  */
 public function create()
 {
     // Make sure a filename is included or Exception
     if (is_null($this->_outputFilename)) {
         throw new \Exception('No Filename Set');
     }
     // Return the created PDF in the selected way
     switch ($this->_letterReturnType) {
         case 0:
             // Return the PDF
             $this->_pdfInstance->output($this->_outputFilename, 'F');
             // Set the document to print at some point today
             if (!is_null($this->_schOverride)) {
                 $scheduledTime = $this->_schOverride;
             } else {
                 $scheduledTime = date('Y-m-d 20:30:00');
             }
             #( (int)date('H') < 14 ) ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00');
             // Get the unix timestamp for the scheduled time
             $unixTimestamp = strtotime($scheduledTime);
             // Check for Saturday and Sunday and add seconds to timestamp accordingly
             if ((int) date("N", $unixTimestamp) == 6) {
                 // Add on 2 days in seconds
                 $unixTimestamp = $unixTimestamp + 172800;
             } else {
                 if ((int) date("N", $unixTimestamp) == 7) {
                     // Add on 1 day in seconds
                     $unixTimestamp = $unixTimestamp + 86400;
                 }
             }
             // Convert the unix timestamp back into the correct time format
             $scheduledTime = date("Y-m-d H:i:s", $unixTimestamp);
             \Printmanager\Queue::add($this->_outputFilename, $scheduledTime);
             break;
         case 1:
             // Return the print details
             $this->_pdfInstance->output($this->_outputFilename, 'F');
             // Set the document to print at some point today
             if (!is_null($this->_schOverride)) {
                 $scheduledTime = $this->_schOverride;
             } else {
                 $scheduledTime = date('Y-m-d 20:30:00');
             }
             #( (int)date('H') < 14 ) ? date('Y-m-d 14:00:00') : date('Y-m-d 20:30:00');
             \Printmanager\Queue::add($this->_outputFilename, $scheduledTime, $this->_trayID);
             break;
         case 2:
             // Return the Download location
             $this->_pdfInstance->output($this->_outputFilename, 'D');
             break;
         case 3:
             // Return the Saved file location
             $this->_pdfInstance->output($this->_outputFilename, 'F');
             break;
     }
     return $this;
 }