Exemplo n.º 1
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) . ')' : ''));
 }
Exemplo n.º 2
0
include $path . 'class' . DIRECTORY_SEPARATOR . 'mysql_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'audit_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'c_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'shahr_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'parvaz_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'parvaz_det_tmp_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'sites_class.php';
include $path . 'class' . DIRECTORY_SEPARATOR . 'havapeima_class.php';
include $path . 'jdf.php';
//-----------------------------------------------------------------------------
$forbidden_colors = array(7 => array('#CCFFCC'));
$sites = sites_class::load();
foreach ($sites as $i => $site) {
    $c = new c_class($site['url']);
    $c->forbidden_colors = isset($forbidden_colors[(int) $site['id']]) ? $forbidden_colors[(int) $site['id']] : array();
    //echo "data from '".$site['url']."'\n";
    $inp = $c->findFlights((int) $site['is_old'] > 0 ? 2 : 0);
    //var_dump($inp);
    //var_dump($inp);
    parvaz_det_tmp_class::add($inp, $site['id'], $site['ghimat']);
}
/*
	$inp=array();
	$inp[] = array('date'=>"2014-5-19","saat"=>"23:59","tedad"=>"9","ghimat"=>1200000,"karmozd"=>"0","parvaz"=>28,"tozihat"=>"");
	$inp[] = array('date'=>"2014-5-18","saat"=>"15:30","tedad"=>"4","ghimat"=>900000,"karmozd"=>"3","parvaz"=>30,"tozihat"=>"ندارد");
	parvaz_det_tmp_class::add($inp,2,0);
	$inp=array();
	$inp[] = array('date'=>"2014-5-18","saat"=>"15:10","tedad"=>"6","ghimat"=>900000,"karmozd"=>"2","parvaz"=>30,"tozihat"=>"ﻥﺩﺍﺭﺩ");
	$inp[] = array('date'=>"2014-5-18","saat"=>"15:10","tedad"=>"6","ghimat"=>900000,"karmozd"=>"2","parvaz"=>31,"tozihat"=>"ﻥﺩﺍﺭﺩ");
	parvaz_det_tmp_class::add($inp,1,0);	
*/