private function _getPurchaseSeries($productId, $from, $to, $type = null)
 {
     $sql = 'select unitPrice, created from `purchaseorderitem` where active = 1 AND productId = :pid AND created >=:from and created <= :to order by created asc';
     $result = Dao::getResultsNative($sql, array('pid' => trim($productId), 'from' => trim($from), 'to' => trim($to)));
     $return = array();
     foreach ($result as $row) {
         $created = new UDate(trim($row['created']));
         $return[] = array($created->format('U') * 1000, (double) trim($row['unitPrice']) * 1.1);
     }
     return $return;
 }
 private function _getXnames()
 {
     $names = array();
     $_12mthAgo = new UDate();
     $_12mthAgo->modify('-12 month');
     for ($i = 0; $i < 12; $i++) {
         $from = new UDate(trim($_12mthAgo->format('Y-m-01 00:00:00')));
         $to = new UDate(trim($_12mthAgo->modify('+1 month')->format('Y-m-01 00:00:00')));
         $names[trim($from->format('M/Y'))] = array('from' => trim($from), 'to' => trim($to));
     }
     return $names;
 }
 private function _getXnames($from, $to, $step)
 {
     $names = array();
     $dateFrom = new UDate(trim($from));
     $dateTo = new UDate(trim($to));
     do {
         $from = new UDate(trim($dateFrom));
         $to = new UDate(trim($dateFrom->modify($step)));
         $names[trim($from->format('d/M/y'))] = array('from' => trim($from), 'to' => trim($to));
     } while ($dateFrom->before($dateTo));
     return $names;
 }
 protected static function _getAttachedFileName()
 {
     $now = new UDate();
     $now->setTimeZone('Australia/Melbourne');
     return 'open_invoice_' . $now->format('Y_m_d_H_i_s') . '.csv';
 }
Exemple #5
0
 /**
  * Getting the items
  *
  * @param unknown $sender
  * @param unknown $param
  * @throws Exception
  *
  */
 public function getItems($sender, $param)
 {
     $results = $errors = array();
     try {
         $class = trim($this->_focusEntity);
         $pageNo = 1;
         $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE;
         if (isset($param->CallbackParameter->pagination)) {
             $pageNo = $param->CallbackParameter->pagination->pageNo;
             $pageSize = $param->CallbackParameter->pagination->pageSize;
         }
         $serachCriteria = isset($param->CallbackParameter->searchCriteria) ? json_decode(json_encode($param->CallbackParameter->searchCriteria), true) : array();
         $where = array(1);
         $params = array();
         if (isset($serachCriteria['taskId']) && trim($taskId = $serachCriteria['taskId']) !== '') {
             $where[] = 'id like :taskId';
             $params['taskId'] = '%' . $taskId . '%';
         }
         if (isset($serachCriteria['ord.id']) && trim($orderIds = $serachCriteria['ord.id']) !== '' && count($orderIds = explode(',', $orderIds)) > 0) {
             $params['entityName'] = 'Order';
             $keys = array();
             foreach ($orderIds as $index => $orderId) {
                 $keys[] = ":" . ($key = "entityId" . $index);
                 $params[$key] = $orderId;
             }
             $where[] = 'fromEntityName = :entityName and fromEntityId in (' . implode(', ', $keys) . ')';
         }
         if (isset($serachCriteria['techId']) && trim($techIds = $serachCriteria['techId']) !== '' && count($techIds = explode(',', $techIds)) > 0) {
             $keys = array();
             foreach ($techIds as $index => $techId) {
                 $keys[] = ":" . ($key = "techId" . $index);
                 $params[$key] = $techId;
             }
             $where[] = 'technicianId in (' . implode(', ', $keys) . ')';
         }
         if (isset($serachCriteria['customer.id']) && trim($customerIds = $serachCriteria['customer.id']) !== '' && count($customerIds = explode(',', $customerIds)) > 0) {
             $keys = array();
             foreach ($customerIds as $index => $customerId) {
                 $keys[] = ":" . ($key = "customerId" . $index);
                 $params[$key] = $customerId;
             }
             $where[] = 'customerId in (' . implode(', ', $keys) . ')';
         }
         if (isset($serachCriteria['statusId']) && count($statusIds = $serachCriteria['statusId']) > 0) {
             $keys = array();
             foreach ($statusIds as $index => $statusId) {
                 $keys[] = ":" . ($key = "statusId" . $index);
                 $params[$key] = $statusId;
             }
             $where[] = 'statusId in (' . implode(', ', $keys) . ')';
         }
         if (isset($serachCriteria['dueDate_from']) && ($dueDate_from = new UDate($serachCriteria['dueDate_from'])) !== false) {
             $where[] = 'dueDate >= :dueDateFrom';
             $params['dueDateFrom'] = $dueDate_from->format('Y-m-d') . ' 00:00:00';
         }
         if (isset($serachCriteria['dueDate_to']) && ($dueDate_to = new UDate($serachCriteria['dueDate_to'])) !== false) {
             $where[] = 'dueDate <= :dueDateTo';
             $params['dueDateTo'] = $dueDate_from->format('Y-m-d') . ' 23:59:59';
         }
         $stats = array();
         $objects = $class::getAllByCriteria(implode(' AND ', $where), $params, false, $pageNo, $pageSize, array('dueDate' => 'asc'), $stats);
         $results['pageStats'] = $stats;
         $results['items'] = array();
         foreach ($objects as $obj) {
             $results['items'][] = $obj->getJson();
         }
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
 /**
  * Getting the view preferences
  * 
  * @return multitype:
  */
 private function _getViewPreference()
 {
     $now = new UDate('now', SystemSettings::getSettings(SystemSettings::TYPE_SYSTEM_TIMEZONE));
     return array('ord_item.eta.from' => $now->format('Y-m-d 00:00:00'), 'ord_item.eta.to' => $now->format('Y-m-d 23:59:59'));
 }
Exemple #7
0
 protected function _debugIncompleteFormat($humanPattern, $time)
 {
     return \UDate::format('DD/MM/YYYY', \UDate::getTimestampFromFormat($humanPattern, $time));
 }
Exemple #8
0
 /**
  * Getting the smart parth
  *
  * @param string $assetId The asset id
  *
  * @return string
  */
 private static function _getSmartPath($assetId)
 {
     $now = new UDate();
     $year = $now->format('Y');
     if (!is_dir($yearDir = trim(self::getRootPath() . DIRECTORY_SEPARATOR . $year))) {
         mkdir($yearDir);
         chmod($yearDir, 0777);
     }
     $month = $now->format('m');
     if (!is_dir($monthDir = trim($yearDir . DIRECTORY_SEPARATOR . $month))) {
         mkdir($monthDir);
         chmod($monthDir, 0777);
     }
     return $monthDir . DIRECTORY_SEPARATOR . $assetId;
 }
 protected static function _getAttachedFileName()
 {
     $now = new UDate();
     $now->setTimeZone('Australia/Melbourne');
     return 'accounting_code_list_' . $now->format('Y_m_d_H_i_s') . '.csv';
 }
 protected static function _getAttachedFileName()
 {
     $now = new UDate();
     $now->setTimeZone('Australia/Melbourne');
     return 'product_magento_import_' . $now->format('Y_m_d_H_i_s') . '.csv';
 }