Exemple #1
0
 /**
  * Пишет решение по арбитражу.
  *
  * @param array $request   параметры решения (текст, процент фрилансеру)
  * @return boolean   успешно?
  */
 function arbResolve($request)
 {
     $must_filled = array('descr_arb', 'reason', 'init', 'result');
     foreach ($must_filled as $f) {
         $this->request['pp_' . $f] = $request['pp_' . $f];
         $this->request[$f] = stripslashes($request[$f]);
         switch ($f) {
             case 'reason':
             case 'result':
                 if ($this->sbr->isNewVersionSbr()) {
                     // В новой версии может быть пусто
                     break;
                 }
             default:
                 if (!trim($this->request[$f])) {
                     $this->error['arbitrage'][$f] = 'Нужно что-нибудь написать';
                 }
                 break;
         }
     }
     $this->request['by_consent'] = $request['by_consent'];
     $this->request['frl_percent'] = $request['frl_percent'];
     if ((int) $this->request['frl_percent'] <= 0 && (int) $request['emp_percent'] <= 0) {
         $this->error['arbitrage']['frl_percent'] = 'Нужно кому-нибудь что-нибудь отдать';
     }
     if ($this->error) {
         return false;
     }
     $frl_percent = $this->request['frl_percent'] / 100;
     $descr_arb = pg_escape_string(change_q_x($this->request['descr_arb'], true, false));
     $reason = pg_escape_string(change_q_x($this->request['reason'], true, false));
     $init = pg_escape_string(change_q_x($this->request['init'], true, false));
     $result = pg_escape_string(change_q_x($this->request['result'], true, false));
     $by_consent = $this->request['by_consent'] ? 'true' : 'false';
     $result_id = is_numeric(substr($request['pp_result'], 0, 1)) ? (int) substr($request['pp_result'], 0, 1) : 0;
     $sql = "\n              UPDATE sbr_stages_arbitrage\n                 SET resolved = now(),\n                     frl_percent = {$frl_percent},\n                     descr_arb = '{$descr_arb}',\n                     reason = '{$reason}',\n                     init = '{$init}',\n                     result = '{$result}',\n                     result_id = {$result_id},\n                     by_consent = {$by_consent}\n               WHERE stage_id = {$this->id}\n            ";
     return $this->_eventQuery($sql);
 }