示例#1
0
function getLoadExcDate($year)
{
    session_start();
    $objResponse = new xajaxResponse();
    if (!hasPermissions('admin')) {
        return $objResponse;
    }
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/LocalDateTime.php';
    $odate = new LocalDateTime();
    $edate = $odate->getExcDaysInit($year, false, false);
    $resp['success'] = true;
    $resp['holidays'] = iconv('windows-1251', 'UTF-8', $edate['holidays']);
    $resp['workdays'] = iconv('windows-1251', 'UTF-8', $edate['workdays']);
    echo json_encode($resp);
}
示例#2
0
文件: pskb.php 项目: uadev/fl-ru-damp
 /**
  * Создает аккредитив. Регистрирует, если необходимо, кошельки для пользователей.
  * В случае создания кошельков банк отправляет пользователям смс с временным паролем.
  * 
  * @param type $sum         Сумма резерва
  * 
  * @return pskb_lc
  */
 public function reserve()
 {
     $lc = $this->getLC();
     $numDog = $this->_sbr->data['id'];
     if ($lc['lc_id'] > 0 && $lc['state'] == self::STATE_ERR) {
         $resp = $this->_checks(json_encode(array('id' => array($lc['lc_id']))));
         $lc_ch = $resp[$lc['lc_id']];
         if ($lc_ch->state == self::STATE_NEW) {
             if ($this->not_different_finance) {
                 return 'no_different';
             } else {
                 $this->upLC(array('lc_id' => null), $lc['lc_id']);
                 // Нужен новый аккредитив, изменились данные резерва
                 $lc['lc_id'] = null;
             }
         } elseif ($lc_ch->state == self::STATE_COVER) {
             $this->upLC(array('state' => 'new'), $lc['lc_id']);
             pskb::checkStatus(array($lc['lc_id']), $in, $out);
             return true;
         }
     }
     if (!$lc) {
         $this->_setError('Ошибка запроса.');
         return false;
     }
     if ($lc['lc_id'] && $lc['state'] == self::STATE_NEW) {
         $this->_setError('Аккредитив уже создан. Ожидается оплата.');
         return false;
     }
     $cdate = new LocalDateTime();
     $cdate->getExcDaysInit(false, true);
     $stages = $this->_sbr->getStages();
     $work_time = 0;
     foreach ($stages as $stage) {
         $work_time += $stage->data['work_time'];
         $cdate->start_time = "now + {$work_time} day";
         $cdate->setTimestamp(strtotime("now + {$work_time} day"));
         $cdate->getWorkForDay(self::TEMP_STAGE_DELAY);
         $work_time += $cdate->getCountDays();
     }
     // Считаем 5 рабочих дней
     $cdate->getWorkForDay(self::DATE_COVER_DELAY, true);
     $cover_time = $cdate->getTimestamp();
     $exec_time = $cover_time + 3600 * 24 * $work_time;
     $end_time = $exec_time + 3600 * 24 * self::DATE_END_DELAY;
     $dateCoverLC = date('d.m.Y', $cover_time);
     $dateExecLC = date('d.m.Y', $exec_time);
     $dateEndLC = date('d.m.Y', $end_time);
     $resp = $this->_addLC($lc['sum'], $this->_sbr->data['id'], $dateExecLC, $dateEndLC, $dateCoverLC, $lc['tagCust'], $lc['alienCust'], $lc['nameCust'], $lc['numCust'], $lc['psCust'], $lc['accCust'], $lc['innCust'], $lc['nameBankCust'], $lc['swiftCust'], $lc['corAccbankCust'], $lc['emailCust'], $lc['cityBankCust'], $lc['cntrBankCust'], $lc['tagPerf'], $lc['alienPerf'], $lc['namePerf'], $lc['numPerf'], $lc['psPerf'], $lc['accPerf'], $lc['innPerf'], $lc['nameBankPerf'], $lc['swiftPerf'], $lc['corAccbankPerf'], $lc['emailPerf'], $lc['cityBankPerf'], $lc['cntrBankPerf'], $this->_sbr->data['cost']);
     $dateCoverLC = date('Y-m-d', $cover_time);
     $dateExecLC = date('Y-m-d', $exec_time);
     $dateEndLC = date('Y-m-d', $end_time);
     if ($resp->id) {
         $data = array('lc_id' => $resp->id, 'dateCoverLC' => $dateCoverLC, 'dateExecLC' => $dateExecLC, 'dateEndLC' => $dateEndLC, 'state' => $resp->state, 'stateReason' => $resp->stateReason);
         $res = $this->upLC($data, $this->_sbr->data['id'], 'sbr_id');
     } else {
         $this->_setError('Ошибка создания аккредитива.');
         $resp = false;
     }
     return $resp;
 }