コード例 #1
0
 public function isValid()
 {
     $isVaild = parent::isValid();
     if ($isVaild) {
         $data = $this->getData();
         $contract = new \Crm\Model\Contract();
         $contract->setId($data['contractId']);
         $contractMapper = $this->getServiceLocator()->get('\\Crm\\Model\\ContractMapper');
         if (!$contractMapper->get($contract)) {
             $this->get('contractId')->setMessages(['Không tìm thấy hợp đồng']);
             $isVaild = false;
         }
     }
     return $isVaild;
 }
コード例 #2
0
ファイル: Media.php プロジェクト: NguyenQuiDuong/Funixtest
 public function uploadContractFile($contractId)
 {
     if (!$contractId) {
         return array('code' => 0, 'messages' => 'Dữ liệu không hợp lệ');
     }
     $contract = new \Crm\Model\Contract();
     $contract->setId($contractId);
     $contractMapper = $this->getServiceLocator()->get('\\Crm\\Model\\ContractMapper');
     if (!$contractMapper->get($contract)) {
         return array('code' => 0, 'messages' => 'Không tìm thấy hợp đồng');
     }
     $adapter = new \Zend\File\Transfer\Adapter\Http();
     $targetFolder = BASE_PATH . '/public/media/contract/' . $contract->getId();
     if (!file_exists($targetFolder)) {
         $oldmask = umask(0);
         mkdir($targetFolder, 0777, true);
         umask($oldmask);
     }
     $adapter->setDestination($targetFolder);
 }
コード例 #3
0
 /**
  *
  * @author KienNN
  */
 public function updatecontractvaluepaidAction()
 {
     $companyId = $this->getRequest()->getQuery('companyId');
     $ids = $this->getRequest()->getQuery('ids');
     $page = $this->getRequest()->getQuery('page');
     $dbSql = $this->getServiceLocator()->get('dbSql');
     $dbAdapter = $this->getServiceLocator()->get('dbAdapter');
     $select = $dbSql->select(array('c' => \Crm\Model\ContractMapper::TABLE_NAME));
     if ($companyId) {
         $select->where(['companyId' => $companyId]);
     }
     if ($ids) {
         $select->where(['id' => explode(',', $ids)]);
     }
     $paginatorAdapter = new \Zend\Paginator\Adapter\DbSelect($select, $dbAdapter);
     $paginator = new \Zend\Paginator\Paginator($paginatorAdapter);
     $paginator->setItemCountPerPage(100);
     $page = $this->getRequest()->getQuery('page', 1);
     $paginator->setCurrentPageNumber($page);
     $contractMapper = $this->getServiceLocator()->get('\\Crm\\Model\\ContractMapper');
     foreach ($paginator as $row) {
         $row = (array) $row;
         $contract = new \Crm\Model\Contract();
         $contract->setId($row['id']);
         $contractMapper->updatePaid2($contract);
         $contractMapper->updateValue($contract);
         unset($contract);
     }
     $this->getViewModel()->setTerminal(true);
     $this->getViewModel()->setVariable('page', $page);
     $this->getViewModel()->setVariable('totalPages', $paginator->count());
     if ($page <= $paginator->count()) {
         $this->getViewModel()->setVariable('redirectUri', '/system/tool/updatecontractvaluepaid?page=' . ($page + 1) . '&companyId=' . $companyId . '&ids=' . $ids);
     }
     $this->getViewModel()->setVariable('defaultRedirectUri', '/system/tool/updatecontractvaluepaid');
     return $this->getViewModel();
 }