Example #1
0
function addclient_exec($Frm, $Err)
{
    if (!$Err) {
        $rnd_pwd = $Frm->GetNmValueI('random_password');
        if ($rnd_pwd) {
            $pwd = generate_pasw(5);
        } else {
            $pwd = $Frm->GetNmValueH('password');
        }
        $eml = trim(strtolower($Frm->GetNmValue('email')));
        if (Client::exist($eml)) {
            $Frm->_gui->informer->ERR("Клиент с таким email уже существует");
            page_reloadAll();
        }
        $filial_id = Filials::check($Frm->GetNmValueI('filial_id'));
        $client_id = Client::create(array('filial_id' => $filial_id, 'fio' => $Frm->GetNmValueH('name'), 'email' => $eml, 'telnum' => $Frm->GetNmValueH('phone'), 'city' => $Frm->GetNmValueH('city'), 'icq' => $Frm->GetNmValueH('icq'), 'skype' => $Frm->GetNmValueH('skype'), 'contacts' => $Frm->GetNmValueH('contacts'), 'about' => $Frm->GetNmValueH('about'), 'ref_id' => $Frm->GetNmValueI('ref'), 'from_id' => $Frm->GetNmValueI('client_from'), 'added_by' => $_SESSION["user"]["data"]["id"], 'password' => $pwd));
        $Frm->_gui->OK("Добавлено");
        switch ($Frm->GetNmValueI('next')) {
            case 0:
                page_reloadSec();
                break;
            case 1:
                header("location: ?section=kln&subsection=2&edit=" . $client_id);
                die;
                break;
            case 2:
                header("location: ?section=ord&subsection=1&kln_id=" . $client_id);
                die;
                break;
        }
    }
}
Example #2
0
 public static function add_client($client_params)
 {
     $result = array('status' => false, 'msg' => '');
     if (empty($client_params['fio'])) {
         $client_params['fio'] = 'Клиент с сайта';
     }
     if (Client::exist($client_params['email'])) {
         $result['msg'] = "Клиент с email - " . $client_params['email'] . " уже существует";
         return $result;
     }
     $date = mktime();
     if (!empty($client_params['filial_id'])) {
         $filial_id = Filials::check($client_params['filial_id']);
     } else {
         $filial_id = Filials::search($client_params['filial']);
         if ((!$filial_id || $filial_id == 9) && !empty($client_params['city'])) {
             $query = "SELECT ftc.filial_id FROM " . TBL_PREF . "data_city dc JOIN " . TBL_PREF . "filial_to_city ftc ON ftc.city_id = dc.id" . " WHERE dc.name = '" . db::input($client_params['city']) . "'";
             $filial_id = db::get_single_value($query);
             if (!$filial_id) {
                 $filial_id = 9;
             }
         }
     }
     $client_id = Client::create(array('filial_id' => $filial_id, 'fio' => $client_params['fio'], 'email' => $client_params['email'], 'telnum' => $client_params['telnum'], 'city' => $client_params['city'], 'liketel' => $client_params['liketel'], 'teltime' => $client_params['teltime'], 'icq' => $client_params['icq'], 'skype' => $client_params['skype'], 'contacts' => $client_params['contacts'], 'blocked' => $client_params['blocked'], 'about' => $client_params['about'], 'ocenka' => $client_params['ocenka'], 'ref_id' => $client_params['ref_id'], 'from_id' => $client_params['from_id'], 'added_by' => $client_params['added_by'], 'orderform' => $client_params['orderform'], 'password' => $client_params['password']));
     return self::generate_response(true, "OK", array('id' => $client_id, 'date' => $date));
 }