Exemple #1
0
 protected function bulkCredit($request)
 {
     $credits = json_decode($request['credits'], true);
     if (!is_array($credits) || empty($credits)) {
         return $this->setError('Input json is invalid', $request);
     }
     $filename = md5(microtime()) . ".json";
     $parsed_rows = array();
     foreach ($credits as $credit) {
         $parsed_row = $this->parseRow($credit);
         if (is_null($parsed_row)) {
             return;
         }
         $parsed_row['file'] = $filename;
         $parsed_rows[] = $parsed_row;
     }
     $options = array('type' => 'credit', 'file_name' => $filename, 'file_content' => json_encode($parsed_rows));
     $receiver = Billrun_Receiver::getInstance($options);
     if ($receiver) {
         $files = $receiver->receive();
         if (!$files) {
             return $this->setError('Couldn\'t receive file', $request);
         }
     } else {
         return $this->setError('Receiver cannot be loaded', $request);
     }
     $this->processBulkCredit();
     $this->getController()->setOutput(array(array('status' => 1, 'desc' => 'success', 'operation' => 'credit', 'stamp' => $options['file_name'], 'input' => $request)));
     return true;
 }
Exemple #2
0
 public function __construct($options)
 {
     parent::__construct($options);
     if (isset($options['workspace'])) {
         $this->workspace = $options['workspace'];
     } else {
         $this->workspace = Billrun_Factory::config()->getConfigValue('ilds.workspace', './workspace/');
     }
 }
Exemple #3
0
 public function __construct($options)
 {
     parent::__construct($options);
     $this->ftpConfig = isset($options['ftp']['host']) ? array($options['ftp']) : $options['ftp'];
     if (isset($options['ftp']['remote_directory'])) {
         $this->ftp_path = $options['ftp']['remote_directory'];
     }
     if (isset($options['workspace'])) {
         $this->workspace = $options['workspace'];
     }
     Zend_Ftp_Factory::registerParserType(Zend_Ftp::UNKNOWN_SYSTEM_TYPE, 'Zend_Ftp_Parser_NsnFtpParser');
     Zend_Ftp_Factory::registerInteratorType(Zend_Ftp::UNKNOWN_SYSTEM_TYPE, 'Zend_Ftp_Directory_NsnIterator');
     Zend_Ftp_Factory::registerFileType(Zend_Ftp::UNKNOWN_SYSTEM_TYPE, 'Zend_Ftp_File_NsnCDRFile');
     Zend_Ftp_Factory::registerDirecotryType(Zend_Ftp::UNKNOWN_SYSTEM_TYPE, 'Zend_Ftp_Directory_Nsn');
 }
Exemple #4
0
 /**
  * method to execute the receive process
  * it's called automatically by the cli main controller
  */
 public function execute()
 {
     $possibleOptions = array('type' => false, 'path' => true, 'workspace' => true);
     if (($options = $this->_controller->getInstanceOptions($possibleOptions)) === FALSE) {
         return;
     }
     $this->getController()->addOutput("Loading receiver");
     $receiver = Billrun_Receiver::getInstance($options);
     $this->getController()->addOutput("Receiver loaded");
     if ($receiver) {
         $this->getController()->addOutput("Starting to receive. This action can take a while...");
         $files = $receiver->receive();
         $this->getController()->addOutput("Received " . count($files) . " files");
     } else {
         $this->getController()->addOutput("Receiver cannot be loaded");
     }
 }
Exemple #5
0
 public function __construct($options)
 {
     parent::__construct($options);
     if (isset($options['workspace'])) {
         $this->workspace = $options['workspace'];
     }
     if (isset($options['path'])) {
         $this->srcPath = $options['path'];
     } else {
         if (isset($options['receiver']['path'])) {
             $this->srcPath = $options['receiver']['path'];
         }
     }
     if (isset($options['receiver']['sort'])) {
         $this->sort = $options['receiver']['sort'];
     }
     if (isset($options['receiver']['order'])) {
         $this->order = $options['receiver']['order'];
     }
 }
Exemple #6
0
 public function __construct($options)
 {
     parent::__construct($options);
     if (isset($options['workspace'])) {
         $this->workspace = $options['workspace'];
         //			if (!file_exists($this->workspace)) {
         //				mkdir($this->workspace, 0755, true);
         //			}
     }
     if (isset($options['file_content'])) {
         $this->file_content = $options['file_content'];
     } else {
         if (isset($options['receiver']['file_content'])) {
             $this->file_content = $options['receiver']['file_content'];
         }
     }
     if (isset($options['file_name'])) {
         $this->filename = $options['file_name'];
     } else {
         if (isset($options['receiver']['file_name'])) {
             $this->filename = $options['receiver']['file_name'];
         }
     }
 }