Esempio n. 1
0
 public function loadByName($name)
 {
     if (trim($name) != '') {
         $name = trim($name);
         $mysql = new mysql_class();
         $ln1 = $mysql->ex_sqlx("insert into shahr_tmp (name) values ('{$name}') ", FALSE);
         $tmp_id = $mysql->insert_id($ln1);
         $mysql->close($ln1);
         $mysql->ex_sql("select name from shahr_tmp where id = {$tmp_id}", $q1);
         if (isset($q1[0])) {
             $name = $q1[0]['name'];
         }
         $mysql->ex_sqlx("delete from shahr_tmp where id = {$tmp_id}");
         $mysql->ex_sql("select * from shahr where name='{$name}'", $q);
         if (isset($q[0])) {
             $r = $q[0];
             $this->id = $q[0]['id'];
             $this->name = $q[0]["name"];
             $this->en_name = $q[0]["en_name"];
         } else {
             $ln = $mysql->ex_sqlx("insert into shahr (name) values ('{$name}') ", FALSE);
             $this->id = $mysql->insert_id($ln);
             $this->name = $name;
             $mysql->close($ln);
         }
     }
 }
Esempio n. 2
0
 public function add($tableName, $data, $query)
 {
     if ($tableName != '') {
         $createTime = date("Y-m-d H:i:s");
         $mysql = new mysql_class();
         $thisId = -1;
         $mysql->enableCache = FALSE;
         $mysql->directQuery("select `id` from `cache` where `tableName` = '{$tableName}' and `query` = '{$query}' ", $q);
         if ($r = $mysql->fetch_array($q)) {
             $thisId = $r['id'];
         }
         if ($thisId > 0) {
             $mysql->directQueryx("update  `cache` set `data` = '" . serialize($data) . "' where `id` = '{$thisId}'");
         } else {
             $ln = $mysql->ex_sqlx("insert into `cache` (`tableName`,`data`,`createTime`,`query`) values('{$tableName}','" . serialize($data) . "','{$createTime}','{$query}') ", FALSE);
             $thisId = (int) $mysql->insert_id($ln);
             $mysql->close($ln);
         }
         $this->id = $thisId;
         $this->tableName = $tableName;
         $this->data = $data;
         $this->query = $query;
         $this->createTime = $createTime;
         $this->viewCount = 1;
     }
     return $this->id;
 }
Esempio n. 3
0
 public function add($sanad_record_id, $tarikh, $mablagh, $log_text)
 {
     $out = -1;
     $mysql = new mysql_class();
     $sql = "insert into `pardakht` (`sanad_record_id`,`tarikh`,`mablagh`,`log_text`) values ('{$sanad_record_id}','{$tarikh}',{$mablagh},'{$log_text}')";
     $conn = $mysql->ex_sqlx($sql, FALSE);
     $out = $mysql->insert_id($conn);
     $mysql->close($conn);
     return $out;
 }
Esempio n. 4
0
 public function add()
 {
     $out = -1;
     $my = new mysql_class();
     $my->ex_sql("select id from `parvaz` where `shomare` = '" . $this->shomare . "'", $q);
     if (isset($q[0])) {
         $out = (int) $q[0]['id'];
     } else {
         $ln = $my->ex_sqlx("insert into parvaz (`shomare`, `name`, `sherkat_id`, `mabda_id`, `maghsad_id`, `havapiema_id`, `ghimat_def`, `zarfiat_def`, `saat_def`, `saat_kh_def`, `poor_def`, `typ_def`, `mablagh_kharid_def`, `customer_id_det`, `rang`, `is_shenavar`, `ghimat_ticket`) values ('" . $this->shomare . "','" . $this->name . "','" . $this->sherkat_id . "','" . $this->mabda_id . "','" . $this->maghsad_id . "','" . $this->havapiema_id . "','" . $this->ghimat_def . "','" . $this->zarfiat_def . "','" . $this->saat_def . "','" . $this->saat_kh_def . "','" . $this->poor_def . "','" . $this->typ_def . "','" . $this->mablagh_kharid_def . "','" . $this->customer_id_det . "','" . $this->rang . "','" . $this->is_shenavar . "','" . $this->ghimat_ticket . "')", FALSE);
         $out = $my->insert_id($ln);
         $my->close($ln);
     }
     return $out;
 }
Esempio n. 5
0
 public function loadByName($name = '')
 {
     if (trim($name) != '') {
         $name = trim($name);
         $mysql = new mysql_class();
         $mysql->ex_sql("select * from havapeima where name='{$name}'", $q);
         if (isset($q[0])) {
             $r = $q[0];
             $this->id = $q[0]['id'];
             $this->name = $q[0]["name"];
         } else {
             $ln = $mysql->ex_sqlx("insert into havapeima (name) values ('{$name}') ", FALSE);
             $this->id = $mysql->insert_id($ln);
             $this->name = $name;
             $mysql->close($ln);
         }
     }
 }
Esempio n. 6
0
function add_item($gname, $table, $fields, $col)
{
    $conf = new conf();
    $mysql = new mysql_class();
    function fieldToId($col, $fieldName)
    {
        $out = -1;
        foreach ($col as $id => $f) {
            if (strpos($id, "new_") === 0 && $id != "new_id" && $id != "new_en") {
                $fields[substr($id, 4)] = $f;
            }
        }
    }
    $min_ticket = 0;
    $mysql->ex_sql("select MAX(`max_ticket`) as `minticket` from `customers` where `en` = 1", $q);
    if (isset($q[0])) {
        $min_ticket = (int) $q[0]["minticket"];
    }
    $min_ticket++;
    $max_ticket = 0;
    $max_ticket = $min_ticket + 999;
    $fields["min_ticket"] = $min_ticket;
    $fields["max_ticket"] = $max_ticket;
    $fi = "(";
    $va = "(";
    foreach ($fields as $key => $value) {
        $fi .= "`{$key}`,";
        $va .= "'{$value}',";
    }
    $fi = substr($fi, 0, -1);
    $va = substr($va, 0, -1);
    $fi .= ")";
    $va .= ")";
    $query = "insert into `{$table}` {$fi} values {$va}";
    $ln = $mysql->ex_sqlx($query, FALSE);
    $out = $mysql->insert_id($ln);
    $mysql->close($ln);
    $ret = $out > 0 ? TRUE : FALSE;
    return $ret;
}
Esempio n. 7
0
function grid1_add($gname, $table, $fields, $col)
{
    $conf = new conf();
    function fieldToId($col, $fieldName)
    {
        $out = -1;
        foreach ($col as $id => $f) {
            if ($f['fieldname'] == $fieldName) {
                $out = $id;
            }
        }
        return $out;
    }
    //$rang = $fields['rang'];
    //$rtmp = explode('#',$rang);
    //if($rtmp[0]!='#')
    $fields["rang"] = "#" . $fields["rang"];
    $fi = "(";
    $valu = "(";
    foreach ($fields as $field => $value) {
        $f_id = fieldToId($col, $field);
        $fn = isset($col[$f_id]['cfunction']) && isset($col[$f_id]['cfunction'][1]) ? $col[$f_id]['cfunction'][1] : '';
        $fi .= "`{$field}`,";
        $valu .= "'" . ($fn != '' ? $fn($value) : $value) . "',";
    }
    $fi = substr($fi, 0, -1);
    $valu = substr($valu, 0, -1);
    $fi .= ")";
    $valu .= ")";
    $query = "insert into `{$table}` {$fi} values {$valu}";
    $mysql = new mysql_class();
    $ln = $mysql->ex_sqlx($query, FALSE);
    $out = $mysql->insert_id($ln);
    $mysql->close($ln);
    $ret = FALSE;
    if ($out > 0) {
        $ret = TRUE;
    }
    return $ret;
}
Esempio n. 8
0
 public function add($data)
 {
     $out = -1;
     $my = new mysql_class();
     $tarikh_p = $data['sal'] . '/' . $data['mah'] . '/' . $data['rooz'];
     $tarikh = $this->inc_model->jalaliToMiladi($tarikh_p);
     $data["tarikh_tavalod"] = $tarikh;
     unset($data["sal"]);
     unset($data["mah"]);
     unset($data["rooz"]);
     unset($data["pass2"]);
     $data['user'] = $data['code_melli'];
     $q = '';
     $f = '';
     $v = '';
     $my->ex_sql("select user,code_melli from user where user='******'user'] . "' or code_melli='" . $data['code_melli'] . "'", $qq);
     if (isset($qq[0])) {
         $tuser = $qq[0]['user'];
         $tcode = $qq[0]['code_melli'];
         if ($tuser == $data['user']) {
             $out += -10;
         }
         if ($tcode == $data['code_melli']) {
             $out += -100;
         }
     } else {
         foreach ($data as $key => $value) {
             $f .= ($f == '' ? '' : ',') . "`{$key}`";
             $v .= ($v == '' ? '' : ',') . "'{$value}'";
         }
         if ($f != '') {
             $q = "insert into `user` ({$f}) values ({$v})";
             $ln = $my->ex_sqlx($q, FALSE);
             $out = $my->insert_id($ln);
             $my->close($ln);
         }
     }
     return $out;
 }
Esempio n. 9
0
 //    if ($ticket_status < 0) {
 //        $out->id = -1;
 //    } else
 if (isset($_SESSION['tprice'])) {
     if ($tprice > 0) {
         //            $tprice = 1000;
         $fextra = '';
         $vextra = '';
         if ($loged) {
             $fextra = ',user_name,agency_id';
             $vextra = ",'" . $_SESSION['user'] . "'," . $conf->gohar_agency_id;
         }
         $my = new mysql_class();
         $ln = $my->ex_sqlx("insert into reserve (refrence_id,total_asli,total_moshtari,user_id,tarikh{$fextra}) values ({$refrence_id},{$aprice},{$tprice},{$user_id},'" . date("Y-m-d H:i:s") . "'{$vextra})", FALSE);
         $rid = $my->insert_id($ln);
         $my->close($ln);
         //https://sep.shaparak.ir/Payment.aspx
         //http://185.55.225.69/bank.php
         /*
          <input name="btype"  type="hidden"  value="saman">
          <input name="wuser"  type="hidden"  value="$wuser">
          <input name="refrence_id"  type="hidden"  value="$refrence_id">
          <input name="wpass"  type="hidden"  value="$wpass">
         */
         $frm = '';
         if ($bank == 'ansar') {
             $SamanMID = "21009067-21056893";
             //"21009082-21056942"; //"10471731";//10247881"; //10156488" Gohar PIN;
             $url .= "reserve3";
             $frm = <<<FORM1
             <form method="post" action="https://ebank.ansarbank.com/cardmanager/controller" id="frmsaman{$tprice}">
Esempio n. 10
0
 public function add($inp_all, $sites_id, $add_ghimat)
 {
     $my = new mysql_class();
     $tmp = '';
     parvaz_det_tmp_class::disable_parvaz_det($sites_id);
     $okDets = array();
     foreach ($inp_all as $inp) {
         $parvaz_id = $inp['parvaz'];
         $tarikh = $inp['date'];
         $saat = $inp['saat'];
         $zarfiat = (int) $inp['tedad'];
         $ghimat = $inp['ghimat'] + $add_ghimat;
         $my->ex_sql("select id,ghimat,zarfiat,en from parvaz_det where parvaz_id={$parvaz_id} and DATE(tarikh) = '{$tarikh}'", $q);
         //$my->ex_sql("select id,ghimat,zarfiat,en from parvaz_det where parvaz_id=$parvaz_id and tarikh='$tarikh' and saat='$saat' ",$q);
         if (isset($q[0])) {
             if ((int) $q[0]['en'] != 0) {
                 $r = $q[0];
                 if ((int) $r['ghimat'] > $ghimat || ((int) $r['ghimat'] == $ghimat and $zarfiat != (int) $r['zarfiat']) || (int) $r['en'] == 3) {
                     $my->ex_sqlx("delete from parvaz_det where id=" . $r['id']);
                     $my->ex_sqlx("insert into parvaz_det (id,parvaz_id,tarikh,saat,zarfiat,ghimat,typ,toz,en) values (" . $r['id'] . ",'{$parvaz_id}','{$tarikh}','{$saat}','{$zarfiat}','{$ghimat}','0',''," . ((int) $q[0]['en'] == 3 ? 1 : $q[0]['en']) . ")");
                     $my->ex_sqlx("update parvaz_det_sites set sites_id={$sites_id} where parvaz_det_id =" . $r['id']);
                 }
             }
             $okDets[] = (int) $r['id'];
         } else {
             $ln = $my->ex_sqlx("insert into parvaz_det (parvaz_id,tarikh,saat,zarfiat,ghimat,typ) values ('{$parvaz_id}','{$tarikh}','{$saat}','{$zarfiat}','{$ghimat}','0')", FALSE);
             $id_inp = (int) $my->insert_id($ln);
             $my->close($ln);
             if ($id_inp > 0) {
                 $okDets[] = (int) $id_inp;
                 $my->ex_sqlx("insert into parvaz_det_sites (parvaz_det_id,sites_id) values ({$id_inp},{$sites_id}) ");
             }
         }
     }
     $my->ex_sqlx("update parvaz_det set en=3 where id in (select parvaz_det_id from parvaz_det_sites where sites_id = {$sites_id}) " . (count($okDets) > 0 ? 'and not id in (' . implode(',', $okDets) . ')' : ''));
 }
Esempio n. 11
0
function addUser($gname, $table, $fields, $column)
{
    $out = FALSE;
    $conf = new conf();
    $mysql = new mysql_class();
    $user = $fields['user'];
    $pass = $fields['pass'];
    $grop_id = $fields['group_id'];
    $fname = $fields['fname'];
    $lname = $fields['lname'];
    $customer_id = $fields['customer_id'];
    $typ = $fields['typ'];
    $mysql->ex_sql("select count(`id`) as `cid` from `user` where `user`='{$user}'", $q);
    if ((int) $q[0]['cid'] == 0) {
        $ln = $mysql->ex_sqlx("insert into `user` (`user`,`pass`,`group_id`,`fname`,`lname`,`customer_id`,`typ`) values ('{$user}','" . md5($pass) . "','{$grop_id}','{$fname}','{$lname}',{$customer_id},{$typ})", FALSE);
        $user_id = $mysql->insert_id($ln);
        $mysql->close($ln);
        if ($user_id > 0) {
            $out = TRUE;
            $arg["toz"] = "اضافه کردن کاربر به نام {$fname} - {$lname}";
            $arg["user_id"] = $_SESSION[$conf->app . "_user_id"];
            $arg["host"] = $_SERVER["REMOTE_ADDR"];
            $arg["page_address"] = $_SERVER["SCRIPT_NAME"];
            $arg["typ"] = 2;
            log_class::add($arg);
        }
    }
    return $out;
}
Esempio n. 12
0
 public static function add_new($tick, $moghim_info, $rwaitlog, $parvaz_det_info, &$ticket_id)
 {
     $mysql = new mysql_class();
     $conf = new conf();
     //$tmp_id= (int)$tmp_id;
     $out = FALSE;
     //$mysql->ex_sql("select `id` from `ticket` where `fname`='".$tick->fname."' and `lname`='".$tick->lname."' and `tel`='".$tick->tel."' and `parvaz_det_id`='".$tick->parvaz_det_id."' and `en`='".$tick->en."' and `mablagh` = '".$tick->mablagh."' and `poorsant` = '".$tick->poorsant."' and `shomare` = '".$tick->shomare."' and `gender` = ".$tick->gender." and email_addr = '".$tick->email_addr."' and sites_id='".$tick->sites_id."' and code_melli='".$tick->code_melli."'",$q);
     //if(count($q)==0 && $tick->lname!="")
     //{
     $mablagh = $tick->mablagh;
     if ($tick->adult == 2) {
         $mablagh = (int) $mablagh / 10;
     }
     $arg["toz"] = "ثبت بلیت به شماره " . $tick->shomare . " کد رهگیری " . ticket_class::rahgiriToCode($tick->sanad_record_id, $conf->rahgiri);
     $arg["user_id"] = isset($_SESSION) ? $_SESSION[$conf->app . "_user_id"] : -1;
     $arg["host"] = $_SERVER["REMOTE_ADDR"];
     $arg["page_address"] = $_SERVER["SCRIPT_NAME"];
     $arg["typ"] = 3;
     log_class::add($arg);
     $hala = date("Y-m-d H:i:s");
     $con = $mysql->ex_sqlx("insert into ticket (`fname`,`lname`,`tel`,`adult`,`sanad_record_id`,`parvaz_det_id`,`customer_id`,`user_id`,`shomare`,`typ`,`en`,`mablagh`,`poorsant`,`gender`,`regtime`,email_addr,sites_id,code_melli,rep,refer,seldate,rwaitlog,parvaz_det_info) values ('" . $tick->fname . "','" . $tick->lname . "','" . $tick->tel . "','" . $tick->adult . "','" . $tick->sanad_record_id . "','" . $tick->parvaz_det_id . "','" . $tick->customer_id . "','" . $tick->user_id . "','" . $tick->shomare . "','" . $tick->typ . "','" . $tick->en . "','{$mablagh}','" . $tick->poorsant . "'," . (int) $tick->gender . ",'{$hala}','" . $tick->email_addr . "','" . $tick->sites_id . "','" . $tick->code_melli . "','" . $moghim_info->rep . "','" . $moghim_info->refer . "','" . $moghim_info->seldate . "','{$rwaitlog}','{$parvaz_det_info}')", FALSE);
     $ticket_id = $mysql->insert_id($con);
     $mysql->close($con);
     $out = TRUE;
     //------------sms------------------
     /*
     				$cust_sms = new customer_class($this->customer_id);
     				
     				if(sms_class::isMobile($this->tel) && $cust_sms->can_sms)
     				{
     					$sms_parvaz = new parvaz_det_class($this->parvaz_det_id);
     					$sms_msg="ازخریدشمامتشکریم\nپرواز:".$sms_parvaz->shomare."\n".audit_class::hamed_pdate($sms_parvaz->tarikh)."\nرهگیری:".$this->rahgiriToCode($this->sanad_record_id,$conf->rahgiri)."\n".$cust_sms->name;
     					sms_class::sendSms($sms_msg,array("$this->tel"),(int)$_SESSION[$conf->app.'_user_id'],$this->sanad_record_id);
     				}*/
     //---------------------------------
     //$out =(($ok=="ok")?TRUE:FALSE);
     //}
     return $out;
 }