Exemplo n.º 1
0
 /**
  * lấy ra danh sách employee bị tạo sau mung 1 thang 8 mà ko phải do đồng bộ về
  * Lấy ra lịch sử tạo tương ứng của employee đó
  * Nếu có lịch sử, echange array cho employee về lịch sử đó, set code= null
  * Nếu chưa có lịch sử, tham chiếu theo user để lấy lại tên, email, các thông tin khác đánh về null hết
  */
 public function revertemployee20150818Action()
 {
     $fromDate = '2015-08-01 00:00:00';
     $dbAdapter = $this->getServiceLocator()->get('dbAdapter');
     $dbSql = $this->getServiceLocator()->get('dbSql');
     $select = $dbSql->select(['e' => \Hrm\Model\EmployeeMapper::TABLE_NAME]);
     $select->where(['createdDateTime >= ?' => $fromDate]);
     $select->where(['createdById != ?' => 1]);
     $select->where(['code IS NOT NULL']);
     $select->where(['oneofficeId IS NOT NULL']);
     $rows = $dbAdapter->query($dbSql->buildSqlString($select), $dbAdapter::QUERY_MODE_EXECUTE);
     $employeeIds = [];
     $employees = [];
     foreach ($rows->toArray() as $row) {
         $employeeIds[$row['id']] = $row['id'];
         $employees[$row['id']] = new \Hrm\Model\Employee($row);
     }
     if (!count($employeeIds)) {
         echo 'Ko timf thaays ban ghi naof';
         die;
     }
     /** lấy ra danh sách employee bị tạo sau mung 1 thang 8 mà ko phải do đồng bộ về*/
     $select = $dbSql->select(['h' => \Hrm\Model\Employee\HistoryMapper::TABLE_NAME]);
     $select->where(['employeeId' => $employeeIds]);
     $select->where(['type' => 1]);
     $select->group(['employeeId']);
     $query = $dbSql->buildSqlString($select);
     $rows = $dbAdapter->query($dbSql->buildSqlString($select), $dbAdapter::QUERY_MODE_EXECUTE);
     $histories = [];
     foreach ($rows->toArray() as $row) {
         $histories[$row['employeeId']] = gzuncompress($row['dataAfter']);
     }
     $this->getViewModel()->setVariable('employees', $employees);
     $this->getViewModel()->setVariable('histories', $histories);
     $employeeMapper = $this->getServiceLocator()->get('\\Hrm\\Model\\EmployeeMapper');
     $userMapper = $this->getServiceLocator()->get('\\User\\Model\\UserMapper');
     foreach ($histories as $employeeId => $history) {
         $history = json_decode($history, true);
         $employee = $employees[$employeeId];
         $userId = $employee->getUserId();
         $employee->exchangeArray($history);
         if ($employee->getBirthdate()) {
             $employee->setBirthdate(DateBase::toCommonDate($employee->getBirthdate()));
         }
         if ($employee->getQuitDate()) {
             $employee->setQuitDate(DateBase::toCommonDate($employee->getQuitDate()));
         }
         if ($employee->getBirthdate()) {
             $employee->setBirthdate(DateBase::toCommonDate($employee->getBirthdate()));
         }
         if ($employee->getReceiveContractDate()) {
             $employee->setReceiveContractDate(DateBase::toCommonDate($employee->getReceiveContractDate()));
         }
         $employee->setCode(null);
         $employee->setOneofficeId(null);
         $employee->setUserId($userId);
         $employeeMapper->save($employee);
         echo 'revert từ history employee ' . $employee->getId();
         echo '<br/>';
         unset($employees[$employeeId]);
     }
     if (count($employees)) {
         foreach ($employees as $employee) {
             $employee->setCode(null);
             $employee->setOneofficeId(null);
             $employee->exchangeArray(array('maritalStatus' => null, 'birthdate' => null, 'birthplace' => null, 'hometown' => null, 'identification' => null, 'identificationPlace' => null, 'identificationDate' => null, 'nation' => null, 'countryId' => null, 'startedDate' => null, 'hasFullPrivilege' => null, 'oneofficeId' => null, 'mobile' => null, 'email' => null, 'yahoo' => null, 'skype' => null, 'facebook' => null, 'religion' => null, 'birthCertificate' => null, 'sittingPositionId' => null, 'workingCityId' => null, 'workingStatus' => null, 'insuranceBookId' => null, 'taxCode' => null, 'bankAccountName' => null, 'bankAccountNumber' => null, 'bankAccountBranch' => null, 'quitDate' => null, 'quitReason' => null, 'quitConfirmedById' => null, 'quitConfirmedDateTime' => null, 'temporateAddress' => null, 'permanentAddress' => null, 'receiveContractDate' => null, 'extraContent' => null));
             $user = $userMapper->get($employee->getUserId());
             if ($user) {
                 $employee->setFullName($user->getFullName());
                 list($lastName, $middleName, $firstName) = Format::splitFullName($employee->getFullName());
                 $employee->setLastName($lastName);
                 $employee->setMiddleName($middleName);
                 $employee->setFirstName($firstName);
                 $employee->setEmail($user->getEmail());
             }
             $employeeMapper->save($employee);
             echo 'Set lại data ' . $employee->getId();
             echo '<br/>';
         }
     }
     die;
     //return $this->getViewModel();
 }
Exemplo n.º 2
0
 private function uploadDocumentFile()
 {
     $documentId = $this->getRequest()->getPost('documentId');
     if (!$documentId) {
         return $this->getJsonModel()->setVariables(array('code' => 0, 'messages' => ['Dữ liệu không hợp lệ']));
     }
     $document = new \Document\Model\Document();
     $document->setId($documentId);
     $documentMapper = $this->getServiceLocator()->get('\\Document\\Model\\DocumentMapper');
     /* @var $documentMapper \Document\Model\DocumentMapper */
     if (!$documentMapper->get($document)) {
         return $this->getJsonModel()->setVariables(array('code' => 0, 'messages' => ['Dữ liệu không hợp lệ']));
     }
     $form = new \Home\Form\Media\DocumentFile($this->getServiceLocator(), ['id' => $document->getId()]);
     $dataPopulate = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getQuery()->toArray(), $this->getRequest()->getFiles()->toArray());
     $dataPopulate['fileUpload']['name'] = Format::removeSigns($dataPopulate['fileUpload']['name']);
     $form->setData($dataPopulate);
     if ($form->isValid()) {
         $formData = $form->getData();
         $file = new \Document\Model\DocumentFile();
         $file->setFileName($formData['fileUpload']['name']);
         $file->setFileSize($formData['fileUpload']['size']);
         $file->setDocumentId($document->getId());
         $file->setCreatedById($this->user()->getIdentity());
         $file->setCreatedDateTime(DateBase::getCurrentDateTime());
         $fileMapper = $this->getServiceLocator()->get('\\Document\\Model\\DocumentFileMapper');
         /* @var $fileMapper \Document\Model\DocumentFileMapper */
         $fileMapper->save($file);
         return $this->getJsonModel()->setVariables(array('code' => 1, 'messages' => $formData));
     } else {
         return $this->getJsonModel()->setVariables(array('code' => 0, 'messages' => $form->getErrorMessagesList()));
     }
 }
Exemplo n.º 3
0
 /**
  */
 public function init()
 {
     $loginUserId = $this->getOption('loginUserId');
     $this->setAttributes(array('id' => 'dgTransaction'));
     $this->addHeader(array('columns' => array(array('name' => 'id', 'content' => 'ID'), array('name' => 'company', 'content' => 'Công ty'), array('name' => 'applyDate', 'content' => 'Ngày hạch toán'), array('name' => 'type', 'content' => 'Loại phiếu'), array('name' => 'totalItems', 'content' => 'Số hạng mục'), array('name' => 'valueBeforeTax', 'content' => 'Giá trị'), array('name' => 'createdBy', 'content' => 'Người tạo'), array('name' => 'approveBy', 'content' => 'Duyệt'), array('name' => 'accountingBy', 'content' => 'Hạch toán'), array('name' => 'action', 'content' => '<i class="fa fa-edit icon"></i>'))));
     if (!$this->getDataSource() instanceof \Zend\Paginator\Paginator || !$this->getDataSource()->getCurrentModels()) {
         return;
     }
     foreach ($this->getDataSource()->getCurrentModels() as $transaction) {
         /*@var $transaction \Accounting\Model\Transaction */
         $row = new Row();
         $this->addRow($row);
         $row->addColumn(array('name' => 'id', 'content' => $transaction->getId()));
         $row->addColumn(array('name' => 'company', 'content' => $transaction->getOption('companyName')));
         $row->addColumn(array('name' => 'applyDate', 'content' => DateBase::toDisplayDate($transaction->getApplyDate())));
         $content = '';
         if ($transaction->getType() == \Accounting\Model\Transaction::TYPE_PAYMENT) {
             $content = '<b class="text-danger">' . $transaction->getTypeName() . '</b>';
         } else {
             $content = '<b class="text-info">' . $transaction->getTypeName() . '</b>';
         }
         $row->addColumn(array('name' => 'type', 'content' => $content));
         $row->addColumn(array('name' => 'totalItem', 'content' => $transaction->getOption('totalItems'), 'attributes' => ['class' => 'colNumber']));
         $row->addColumn(array('name' => 'valueBeforeTax', 'content' => \Home\Model\Format::toNumber($transaction->getOption('valueBeforeTax')), 'attributes' => ['class' => 'colNumber']));
         $content = [];
         if ($transaction->getOption('createdBy')) {
             $content[] = '<div>' . ($transaction->getOption('createdBy')->getFullName() ?: $transaction->getOption('createdBy')->getEmail()) . '</div>';
         }
         $content[] = '<div><i class="date">' . DateBase::toDisplayDateTime($transaction->getCreatedDateTime()) . '</i></div>';
         $row->addColumn(array('name' => 'createdBy', 'content' => implode('', $content)));
         $content = [];
         if ($transaction->getApprovedById()) {
             if ($transaction->getStatus() == \Accounting\Model\Transaction::STATUS_APPROVED) {
                 if ($transaction->getOption('approvedBy')) {
                     $content[] = '<div class="text-success"><b>Duyệt: </b>' . ($transaction->getOption('approvedBy')->getFullName() ?: $transaction->getOption('approvedBy')->getEmail()) . '</div>';
                 }
                 if ($transaction->getApprovedDateTime()) {
                     $content[] = '<div class="text-success"><i class="date">' . DateBase::toDisplayDateTime($transaction->getApprovedDateTime()) . '</i></div>';
                 }
                 $content[] = '<a href="/accounting/transaction/approvereq?id=' . $transaction->getId() . '">Hủy duyệt</a>';
             } elseif ($transaction->getStatus() == \Accounting\Model\Transaction::STATUS_INAPPROVED) {
                 if ($transaction->getOption('approvedBy')) {
                     $content[] = '<div class="text-danger"><b>Hủy: </b>' . ($transaction->getOption('approvedBy')->getFullName() ?: $transaction->getOption('approvedBy')->getEmail()) . '</div>';
                 }
                 if ($transaction->getApprovedDateTime()) {
                     $content[] = '<div class="text-danger"><i class="date">' . DateBase::toDisplayDateTime($transaction->getApprovedDateTime()) . '</i></div>';
                 }
                 $content[] = '<a href="/accounting/transaction/approvereq?id=' . $transaction->getId() . '">Duyệt</a>';
             } else {
                 if ($transaction->getOption('approvedBy')) {
                     $content[] = '<div class="text-success"><b>Duyệt: </b>' . ($transaction->getOption('approvedBy')->getFullName() ?: $transaction->getOption('approvedBy')->getEmail()) . '</div>';
                 }
                 if ($transaction->getApprovedDateTime()) {
                     $content[] = '<div class="text-success"><i class="date">' . DateBase::toDisplayDateTime($transaction->getApprovedDateTime()) . '</i></div>';
                 }
             }
         } else {
             $content[] = '<a href="/accounting/transaction/approvereq?id=' . $transaction->getId() . '">Duyệt</a>';
         }
         $row->addColumn(array('name' => 'approvedBy', 'content' => implode('', $content), 'attributes' => ['class' => 'colControls']));
         $content = [];
         if ($transaction->getAccountingById()) {
             if ($transaction->getOption('accountingBy')) {
                 $content[] = '<div>' . ($transaction->getOption('accountingBy')->getFullName() ?: $transaction->getOption('accountingBy')->getEmail()) . '</div>';
             }
             if ($transaction->getAccountingDateTime()) {
                 $content[] = '<div><i class="date">' . DateBase::toDisplayDateTime($transaction->getAccountingDateTime()) . '</i></div>';
             }
         } else {
             $content[] = '<a href="/accounting/transaction/accountingreq?id=' . $transaction->getId() . '">Duyệt</a>';
         }
         $row->addColumn(array('name' => 'accountingBy', 'content' => implode('', $content), 'attributes' => ['class' => 'colControls']));
         /** @todo: đang đợi chỉ thị để làm nốt
             $content = [];
             if($transaction->getPaymentById()){
                 if($transaction->getOption('paymentBy')){
                     $content[] = '<div>'.($transaction->getOption('paymentBy')->getFullName()
                         ?:$transaction->getOption('paymentBy')->getEmail()).'</div>';
                 }
                 if($transaction->getPaymentDateTime()){
                     $content[] = '<div><i class="date">'.DateBase::toDisplayDateTime($transaction->getPaymentDateTime()).'</i></div>';
                 }
             } else {
                 $content[] = '<a href="/accounting/transaction/payment?id='.$transaction->getId().'">Duyệt</a>';
             }
             $row->addColumn(array(
                 'name' => 'paymentBy',
                 'content' => implode('', $content),
                 'attributes' => ['class' => 'colControls']
             )); */
         $content = [];
         if ($transaction->getStatus() == \Accounting\Model\Transaction::STATUS_NEW) {
             if ($transaction->getCreatedById() == $loginUserId) {
                 $content[] = '<a class="fa fa-edit icon" href="/accounting/transaction/editreq?id=' . $transaction->getId() . '"></a>';
             }
         }
         $row->addColumn(array('name' => 'action', 'content' => implode('', $content), 'attributes' => ['class' => 'colControls']));
     }
 }