コード例 #1
0
ファイル: processor.php プロジェクト: tomasz-m/realmGenerator
function getTypeName($val, $argument = null)
{
    $type = gettype($val);
    global $detectDateMode;
    switch ($type) {
        case "string":
            if ($detectDateMode == 1 && isDate($val)) {
                return "Date";
            } else {
                if ($detectDateMode == 2 && (bool) strtotime($val)) {
                    return "Date";
                } else {
                    return "String";
                }
            }
        case "integer":
            return "int";
        case "double":
            return "float";
        case "boolean":
            return "boolean";
        case "array":
            if (is_numeric(key($val))) {
                return "RealmList<" . $argument . ">";
            } else {
                return $argument;
            }
    }
    return null;
}
コード例 #2
0
 /**
  * Get array of articles
  * 
  * For each article, set the article date.
  * The article date can be the creation date or the publish_on date if exists
  *
  * @access	public
  * @param 	array	An associative array
  * @return	array	Array of records
  *
  */
 function get_list($where = FALSE)
 {
     $data = array();
     $this->db->select($this->lang_table . '.*');
     $this->db->join($this->lang_table, $this->lang_table . '.id_' . $this->table . ' = ' . $this->table . '.id_' . $this->table, 'inner');
     $this->db->where($this->lang_table . '.lang', Settings::get_lang('default'));
     $data = parent::get_list($where);
     // Set the correct publish date
     foreach ($data as $key => $row) {
         $data[$key]['date'] = isDate($row['publish_on']) ? $row['publish_on'] : $row['created'];
     }
     return $data;
 }
コード例 #3
0
 function valid_datetime_object($t)
 {
     //only date
     if (type($t) == '_Date') {
         $y = $t->get_date();
     } elseif (type($t) == 'DateTime') {
         $y = $t;
     }
     if (isStr($t) && isDate($t)) {
         $s = explode('-', $t);
         $y = new DateTime();
         $y->setDate($s[0], $s[1], $s[2]);
     }
     if (isset($y)) {
         return $y;
     } else {
         return false;
     }
 }
コード例 #4
0
ファイル: ajax_gestion.php プロジェクト: Kloadut/noalyss_ynh
 require_once NOALYSS_INCLUDE . '/class_follow_up.php';
 /**
  * save info from the get
  */
 $date_event = HtmlInput::default_value_get("date_event", -1);
 $dest = HtmlInput::default_value_get("dest", "");
 $event_group = HtmlInput::default_value_get("event_group", 0);
 $event_priority = HtmlInput::default_value_get("event_priority", 0);
 $title = HtmlInput::default_value_get("title_event", NULL);
 $summary = HtmlInput::default_value_get("summary", "");
 $type_event = HtmlInput::default_value_get('type_event', -1);
 /*
  * Check if data are valid
  */
 try {
     if ($date_event == -1 || isDate($date_event) == 0) {
         throw new Exception(_('Date invalide'));
     }
     if (trim($dest) == "") {
         $dest_id = NULL;
     } else {
         $fiche = new Fiche($cn);
         $fiche->get_by_qcode($dest);
         $dest_id = $fiche->id;
         if ($dest_id == 0) {
             throw new Exception(_('Destinataire invalide'));
         }
     }
     if ($type_event == -1) {
         throw new Exception(_('Type invalide'));
     }
コード例 #5
0
 }
 $strKey = substr_replace($strKey, "", -1);
 $strVal = substr_replace($strVal, "", -2);
 $query = "insert into debitur\r\n                            ({$strKey},usercreate,userupdate,action,tgl_update) \r\n                    values({$strVal},'{$userCreate}','{$userCreate}','{$datenow}','{$datenow}');";
 $buf = cleanstr($db_function->exec($query));
 if ($buf == "") {
     //--insert trail
     $strKey = "";
     $strVal = "'";
     $frmTrail = $_POST['frm'];
     $nonTrail = array('usercreate', 'action');
     foreach ($nonTrail as $row) {
         unset($frmTrail[$row]);
     }
     foreach ($frmTrail as $key => $val) {
         if (isDate($val)) {
             $val = balikTgl($val);
         }
         $strKey .= $key . ",";
         $strVal .= trim($val) . "','";
     }
     $strKey = substr_replace($strKey, "", -1);
     $strVal = substr_replace($strVal, "", -2);
     $query = "insert into debitur_trail\r\n                                (no_trail,{$strKey},userupdate,tgl_update) \r\n                        values('1',{$strVal},'{$userCreate}',now());";
     $buf = cleanstr($db_function->exec($query));
     if ($buf != "") {
         cleanstr($db_function->exec("delete from debitur where noaplikasi='" . $_POST['frm']['noaplikasi'] . "'"));
     }
 }
 //------------
 if ($buf != "") {
コード例 #6
0
 public function verify()
 {
     if (isDate($this->tl_date) == false) {
         $this->tl_date = date('d.m.Y');
     }
     return 0;
 }
コード例 #7
0
 function check()
 {
     /*
      * check date
      */
     if ($this->from != '' && isDate($this->from) == 0 || $this->to != '' && isDate($this->to) == 0) {
         return -1;
     }
     return 0;
 }
コード例 #8
0
ファイル: ac_common.php プロジェクト: Kloadut/noalyss_ynh
/**
 * \brief  Compare 2 dates
 * \param p_date
 * \param p_date_oth
 *
 * \return
 *      - == 0 les dates sont identiques
 *      - > 0 date1 > date2
 *      - < 0 date1 < date2
 */
function cmpDate($p_date, $p_date_oth)
{
    date_default_timezone_set('Europe/Brussels');
    $l_date = isDate($p_date);
    $l2_date = isDate($p_date_oth);
    if ($l_date == null || $l2_date == null) {
        throw new Exception("erreur date [{$p_date}] [{$p_date_oth}]");
    }
    $l_adate = explode(".", $l_date);
    $l2_adate = explode(".", $l2_date);
    $l_mkdate = mktime(0, 0, 0, $l_adate[1], $l_adate[0], $l_adate[2]);
    $l2_mkdate = mktime(0, 0, 0, $l2_adate[1], $l2_adate[0], $l2_adate[2]);
    // si $p_date > $p_date_oth return > 0
    return $l_mkdate - $l2_mkdate;
}
コード例 #9
0
function whiteWebStat($content)
{
    $splStr = '';
    $splxx = '';
    $filePath = '';
    $nCount = '';
    $url = '';
    $s = '';
    $visitUrl = '';
    $viewUrl = '';
    $viewdatetime = '';
    $ip = '';
    $browser = '';
    $operatingsystem = '';
    $cookie = '';
    $screenwh = '';
    $moreInfo = '';
    $ipList = '';
    $dateClass = '';
    $splxx = aspSplit($content, vbCrlf() . '-------------------------------------------------' . vbCrlf());
    $nCount = 0;
    foreach ($splxx as $key => $s) {
        if (inStr($s, '当前:') > 0) {
            $nCount = $nCount + 1;
            $s = vbCrlf() . $s . vbCrlf();
            $dateClass = ADSql(getFileAttr($filePath, '3'));
            $visitUrl = ADSql(getStrCut($s, vbCrlf() . '来访', vbCrlf(), 0));
            $viewUrl = ADSql(getStrCut($s, vbCrlf() . '当前:', vbCrlf(), 0));
            $viewdatetime = ADSql(getStrCut($s, vbCrlf() . '时间:', vbCrlf(), 0));
            $ip = ADSql(getStrCut($s, vbCrlf() . 'IP:', vbCrlf(), 0));
            $browser = ADSql(getStrCut($s, vbCrlf() . 'browser: ', vbCrlf(), 0));
            $operatingsystem = ADSql(getStrCut($s, vbCrlf() . 'operatingsystem=', vbCrlf(), 0));
            $cookie = ADSql(getStrCut($s, vbCrlf() . 'Cookies=', vbCrlf(), 0));
            $screenwh = ADSql(getStrCut($s, vbCrlf() . 'Screen=', vbCrlf(), 0));
            $moreInfo = ADSql(getStrCut($s, vbCrlf() . '用户信息=', vbCrlf(), 0));
            $browser = ADSql(getBrType($moreInfo));
            if (inStr(vbCrlf() . $ipList . vbCrlf(), vbCrlf() . $ip . vbCrlf()) == false) {
                $ipList = $ipList . $ip . vbCrlf();
            }
            $viewdatetime = replace($viewdatetime, '来访', '00');
            if (isDate($viewdatetime) == false) {
                $viewdatetime = '1988/07/12 10:10:10';
            }
            $screenwh = left($screenwh, 20);
            if (1 == 2) {
                aspEcho('编号', $nCount);
                aspEcho('dateClass', $dateClass);
                aspEcho('visitUrl', $visitUrl);
                aspEcho('viewUrl', $viewUrl);
                aspEcho('viewdatetime', $viewdatetime);
                aspEcho('IP', $ip);
                aspEcho('browser', $browser);
                aspEcho('operatingsystem', $operatingsystem);
                aspEcho('cookie', $cookie);
                aspEcho('screenwh', $screenwh);
                aspEcho('moreInfo', $moreInfo);
                HR();
            }
            connexecute('insert into ' . $GLOBALS['db_PREFIX'] . 'websitestat (visiturl,viewurl,browser,operatingsystem,screenwh,moreinfo,viewdatetime,ip,dateclass) values(\'' . $visitUrl . '\',\'' . $viewUrl . '\',\'' . $browser . '\',\'' . $operatingsystem . '\',\'' . $screenwh . '\',\'' . $moreInfo . '\',\'' . $viewdatetime . '\',\'' . $ip . '\',\'' . $dateClass . '\')');
        }
    }
}
コード例 #10
0
ファイル: class_periode.php プロジェクト: Kloadut/noalyss_ynh
 function insert($p_date_start, $p_date_end, $p_exercice)
 {
     try {
         if (isDate($p_date_start) == null || isDate($p_date_end) == null || strlen(trim($p_exercice)) == 0 || (string) $p_exercice != (string) (int) $p_exercice || $p_exercice < COMPTA_MIN_YEAR || $p_exercice > COMPTA_MAX_YEAR) {
             throw new Exception("Paramètre invalide");
         }
         $p_id = $this->cn->get_next_seq('s_periode');
         $sql = sprintf(" insert into parm_periode(p_id,p_start,p_end,p_closed,p_exercice)" . "values (%d,to_date('%s','DD.MM.YYYY'),to_date('%s','DD.MM.YYYY')" . ",'f','%s')", $p_id, $p_date_start, $p_date_end, $p_exercice);
         $this->cn->start();
         $Res = $this->cn->exec_sql($sql);
         $Res = $this->cn->exec_sql("insert into jrn_periode (jrn_def_id,p_id,status) " . "select jrn_def_id,{$p_id},'OP' from jrn_def");
         $this->cn->commit();
     } catch (Exception $e) {
         $this->cn->rollback();
         return 1;
     }
     return 0;
 }
コード例 #11
0
ファイル: Time.php プロジェクト: 313801120/AspPhpCms
function format_Time($timeStr, $nType)
{
    $y = '';
    $m = '';
    $d = '';
    $h = '';
    $mi = '';
    $s = '';
    $format_Time = '';
    if (isDate($timeStr) == false) {
        return @$format_Time;
    }
    $y = cStr(year($timeStr));
    $m = cStr(month($timeStr));
    if (len($m) == 1) {
        $m = '0' . $m;
    }
    $d = cStr(day($timeStr));
    //在vb.net里要这样用  D = CStr(CDate(timeStr).Day)
    if (len($d) == 1) {
        $d = '0' . $d;
    }
    $h = cStr(hour($timeStr));
    if (len($h) == 1) {
        $h = '0' . $h;
    }
    $mi = cStr(minute($timeStr));
    if (len($mi) == 1) {
        $mi = '0' . $mi;
    }
    $s = cStr(second($timeStr));
    if (len($s) == 1) {
        $s = '0' . $s;
    }
    switch ($nType) {
        case 1:
            //yyyy-mm-dd hh:mm:ss
            $format_Time = $y . '-' . $m . '-' . $d . ' ' . $h . ':' . $mi . ':' . $s;
            break;
        case 2:
            //yyyy-mm-dd
            $format_Time = $y . '-' . $m . '-' . $d;
            break;
        case 3:
            //hh:mm:ss
            $format_Time = $h . ':' . $mi . ':' . $s;
            break;
        case 4:
            //yyyy年mm月dd日
            $format_Time = $y . '年' . $m . '月' . $d . '日';
            break;
        case 5:
            //yyyymmdd
            $format_Time = $y . $m . $d;
            break;
        case 6:
            //yyyymmddhhmmss
            $format_Time = $y . $m . $d . $h . $mi . $s;
            break;
        case 7:
            //mm-dd
            $format_Time = $m . '-' . $d;
            break;
        case 8:
            //yyyy年mm月dd日
            $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . ':' . $mi . ':' . $s;
            break;
        case 9:
            //yyyy年mm月dd日H时mi分S秒 早上
            $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . '时' . $mi . '分' . $s . '秒,' . getDayStatus($h, 1);
            break;
        case 10:
            //yyyy年mm月dd日H时
            $format_Time = $y . '年' . $m . '月' . $d . '日' . $h . '时';
            break;
        case 11:
            //yyyy年mm月dd日H时mi分S秒
            $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . '时' . $mi . '分' . $s . '秒';
            break;
        case 12:
            //yyyy年mm月dd日H时mi分
            $format_Time = $y . '年' . $m . '月' . $d . '日' . ' ' . $h . '时' . $mi . '分';
            break;
        case 13:
            //yyyy年mm月dd日H时mi分 早上
            $format_Time = $m . '月' . $d . '日' . ' ' . $h . ':' . $mi . ' ' . getDayStatus($h, 0);
            break;
        case 14:
            //yyyy年mm月dd日
            $format_Time = $y . '/' . $m . '/' . $d;
            break;
        case 15:
            //yyyy年mm月 第1周
            $format_Time = $y . '年' . $m . '月 第' . GetCountPage($d, 7) . '周';
    }
    return @$format_Time;
}
コード例 #12
0
 public static function date(FTL_Binding $tag)
 {
     if (!isDate($tag->locals->comment["created"])) {
         return;
     }
     return $tag->locals->comment["created"];
 }
コード例 #13
0
ファイル: ajax_ledger.php プロジェクト: Kloadut/noalyss_ynh
    case 'save':
        ob_start();
        try {
            $cn->start();
            if ($access == "W") {
                if (isset($_POST['p_ech'])) {
                    $ech = $_POST['p_ech'];
                    if (trim($ech) != '' && isDate($ech) != null) {
                        $cn->exec_sql("update jrn set jr_ech=to_date(\$1,'DD.MM.YYYY') where jr_id=\$2", array($ech, $jr_id));
                    } else {
                        $cn->exec_sql("update jrn set jr_ech=null where jr_id=\$1", array($jr_id));
                    }
                }
                if (isset($_POST['p_date_paid'])) {
                    $ech = $_POST['p_date_paid'];
                    if (trim($ech) != '' && isDate($ech) != null) {
                        $cn->exec_sql("update jrn set jr_date_paid=to_date(\$1,'DD.MM.YYYY') where jr_id=\$2", array($ech, $jr_id));
                    } else {
                        $cn->exec_sql("update jrn set jr_date_paid=null where jr_id=\$1", array($jr_id));
                    }
                }
                $cn->exec_sql("update jrn set jr_comment=\$1,jr_pj_number=\$2,jr_date=to_date(\$4,'DD.MM.YYYY') where jr_id=\$3", array($_POST['lib'], $_POST['npj'], $jr_id, $_POST['p_date']));
                $cn->exec_sql("update jrnx set j_date=to_date(\$1,'DD.MM.YYYY') where j_grpt in (select jr_grpt_id from jrn where jr_id=\$2)", array($_POST['p_date'], $jr_id));
                $cn->exec_sql('update operation_analytique set oa_date=j_date from jrnx
				where
				operation_analytique.j_id=jrnx.j_id  and
				operation_analytique.j_id in (select j_id
						from jrnx join jrn on (j_grpt=jr_grpt_id)
						where jr_id=$1)
						', array($jr_id));
                $cn->exec_sql("select comptaproc.jrn_add_note(\$1,\$2)", array($jr_id, $_POST['jrn_note']));
コード例 #14
0
 /**
  * Verify that data are correct
  * @throws Exception
  */
 function verify()
 {
     if ($this->dt_id == -1) {
         throw new Exception(_('Type action invalide'), 10);
     }
     if (isDate($this->ag_timestamp) != $this->ag_timestamp) {
         throw new Exception(_('Date invalide'), 20);
     }
     if (isDate($this->ag_remind_date) != $this->ag_remind_date) {
         throw new Exception(_('Date invalide'), 30);
     }
     if ($this->f_id_dest == 0) {
         $this->f_id_dest = null;
     }
 }
コード例 #15
0
echo tr($r);
// limit of the year
$exercice = $g_user->get_exercice();
$periode = new Periode($cn);
list($first_per, $last_per) = $periode->get_limit($exercice);
$start = new IDate('start');
if (isset($_GET['start']) && isDate($_GET['start']) == null) {
    echo alert(_('Date malformée, désolé'));
    $_GET['start'] = $first_per->first_day();
}
$start->value = isset($_GET['start']) ? $_GET['start'] : $first_per->first_day();
$r = td(_('Date début'));
$r .= td($start->input());
echo tr($r);
$end = new IDate('end');
if (isset($_GET['end']) && isDate($_GET['end']) == null) {
    echo alert(_('Date malformée, désolé'));
    $_GET['end'] = $last_per->last_day();
}
$end->value = isset($_GET['end']) ? $_GET['end'] : $last_per->last_day();
$r = td(_('Date fin'));
$r .= td($end->input());
echo tr($r);
// type of lettering : all, lettered, not lettered
$sel = new ISelect('type_let');
$sel->value = array(array('value' => 0, 'label' => _('Toutes opérations')), array('value' => 1, 'label' => _('Opérations lettrées')), array('value' => 3, 'label' => _('Opérations lettrées montants différents')), array('value' => 2, 'label' => _('Opérations NON lettrées')));
if (isset($_GET['type_let'])) {
    $sel->selected = $_GET['type_let'];
}
$r = td("Filtre ") . td($sel->input());
echo tr($r);
コード例 #16
0
 /**
 * @brief this function will create a sql stmt to use to create the list for
 * the ledger,
 * @param$p_array is usually the $_GET,
 * @param$p_order the order of the row
 * @param$p_where is the sql condition if not null then the $p_array will not be used
 * \note the p_action will be used to filter the ledger but gl means ALL
 * struct array $p_array
  \verbatim
  (
  [gDossier] => 13
  [p_jrn] => -1
  [date_start] =>
  [date_end] =>
  [amount_min] => 0
  [amount_max] => 0
  [desc] =>
  [search] => Rechercher
  [p_action] => ven
  [sa] => l
  )
  \endverbatim
 * \return an array with a valid sql statement, an the where clause => array[sql] array[where]
 * \see list_operation
 * \see display_search_form
 * \see search_form
 */
 public function build_search_sql($p_array, $p_order = "", $p_where = "")
 {
     $sql = "select jr_id\t,\n             jr_montant,\n             substr(jr_comment,1,60) as jr_comment,\n             to_char(jr_ech,'DD.MM.YY') as str_jr_ech,\n             to_char(jr_date,'DD.MM.YY') as str_jr_date,\n             jr_date as jr_date_order,\n             jr_grpt_id,\n             jr_rapt,\n             jr_internal,\n             jrn_def_id,\n             jrn_def_name,\n             jrn_def_ech,\n             jrn_def_type,\n             jr_valid,\n             jr_tech_per,\n             jr_pj_name,\n             p_closed,\n             jr_pj_number,\n             n_text,\n\t     case\n\t     when jrn_def_type='VEN' then\n\t\t (select ad_value from fiche_detail where ad_id=1\n\t\t and f_id=(select max(qs_client) from quant_sold join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))\n\t    when jrn_def_type = 'ACH' then\n\t\t(select ad_value from fiche_detail where ad_id=1\n\t\tand f_id=(select max(qp_supplier) from quant_purchase join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))\n\t    when jrn_def_type = 'FIN' then\n\t\t(select ad_value from fiche_detail where ad_id=1\n\t\tand f_id=(select qf_other from quant_fin where quant_fin.jr_id=x.jr_id))\n\t    end as name,\n\t   case\n\t     when jrn_def_type='VEN' then (select ad_value from fiche_detail where ad_id=32 and f_id=(select max(qs_client) from quant_sold join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))\n\t    when jrn_def_type = 'ACH' then (select ad_value from fiche_detail where ad_id=32 and f_id=(select max(qp_supplier) from quant_purchase join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))\n\t    when jrn_def_type = 'FIN' then (select ad_value from fiche_detail where ad_id=32 and f_id=(select qf_other from quant_fin where quant_fin.jr_id=x.jr_id))\n\t    end as first_name,\n\t    case\n\t     when jrn_def_type='VEN' then (select ad_value from fiche_detail where ad_id=23 and f_id=(select max(qs_client) from quant_sold join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))\n\t    when jrn_def_type = 'ACH' then (select ad_value from fiche_detail where ad_id=23 and f_id=(select max(qp_supplier) from quant_purchase join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))\n\t    when jrn_def_type = 'FIN' then (select ad_value from fiche_detail where ad_id=23 and f_id=(select qf_other from quant_fin where quant_fin.jr_id=x.jr_id))\n\t    end as quick_code,\n\t    case\n\t     when jrn_def_type='VEN' then\n\t\t     (select sum(qs_price)+sum(vat) from\n\t\t\t\t(select qs_internal,qs_price,case when qs_vat_sided<>0 then 0 else qs_vat end as vat from quant_sold where qs_internal=X.jr_internal) as ven_invoice\n\t\t\t  )\n\t    when jrn_def_type = 'ACH' then\n\t\t\t(\n\t\t\t\tselect sum(qp_price)+sum(vat)+sum(qp_nd_tva)+sum(qp_nd_tva_recup)\n\t\t\t\tfrom\n\t\t\t\t (select qp_internal,qp_price,qp_nd_tva,qp_nd_tva_recup,qp_vat-qp_vat_sided as vat from quant_purchase where qp_internal=X.jr_internal) as invoice_purchase\n\t\t\t)\n\t\telse null\n\t\tend as total_invoice,\n            jr_date_paid,\n            to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid\n             from\n             jrn as X left join jrn_note using(jr_id)\n             join jrn_def on jrn_def_id=jr_def_id\n             join parm_periode on p_id=jr_tech_per";
     if (!empty($p_array)) {
         extract($p_array);
     }
     if (isset($op)) {
         $r_jrn = isset(${$op . "r_jrn"}) ? ${$op . "r_jrn"} : -1;
     } else {
         $r_jrn = isset($r_jrn) ? $r_jrn : -1;
     }
     /* if no variable are set then give them a default
      * value */
     if ($p_array == null || empty($p_array) || !isset($amount_min)) {
         $amount_min = 0;
         $amount_max = 0;
         $desc = '';
         $qcode = isset($qcode) ? $qcode : "";
         if (isset($qcodesearch_op)) {
             $qcode = $qcodesearch_op;
         }
         $accounting = isset($accounting) ? $accounting : "";
         $periode = new Periode($this->db);
         $g_user = new User($this->db);
         $p_id = $g_user->get_periode();
         if ($p_id != null) {
             list($date_start, $date_end) = $periode->get_date_limit($p_id);
         }
     }
     /* if p_jrn : 0 if means all ledgers, if -1 means all ledger of this
      *  type otherwise only one ledger */
     $fil_ledger = '';
     $fil_amount = '';
     $fil_date = '';
     $fil_desc = '';
     $fil_sec = '';
     $fil_qcode = '';
     $fil_account = '';
     $fil_paid = '';
     $fil_date_paid = '';
     $and = '';
     $g_user = new User($this->db);
     $p_action = $ledger_type;
     if ($p_action == '') {
         $p_action = 'ALL';
     }
     if ($r_jrn == -1) {
         /* from compta.php the p_action is quick_writing instead of ODS  */
         if ($p_action == 'quick_writing') {
             $p_action = 'ODS';
         }
         $fil_ledger = $g_user->get_ledger_sql($p_action, 3);
         $and = ' and ';
     } else {
         if ($p_action == 'quick_writing') {
             $p_action = 'ODS';
         }
         $aLedger = $g_user->get_ledger($p_action, 3);
         $fil_ledger = '';
         $sp = '';
         for ($i = 0; $i < count($r_jrn); $i++) {
             if (isset($r_jrn[$i])) {
                 $a = $r_jrn[$i];
                 $fil_ledger .= $sp . $a;
                 $sp = ',';
             }
         }
         $fil_ledger = ' jrn_def_id in (' . $fil_ledger . ')';
         $and = ' and ';
         /* no ledger selected */
         if ($sp == '') {
             $fil_ledger = '';
             $and = '';
         }
     }
     /* format the number */
     $amount_min = abs(toNumber($amount_min));
     $amount_max = abs(toNumber($amount_max));
     if ($amount_min > 0 && isNumber($amount_min)) {
         $fil_amount = $and . ' jr_montant >=' . $amount_min;
         $and = ' and ';
     }
     if ($amount_max > 0 && isNumber($amount_max)) {
         $fil_amount .= $and . ' jr_montant <=' . $amount_max;
         $and = ' and ';
     }
     /* -------------------------------------------------------------------------- *
      * if both amount are the same then we need to search into the detail
      * and we reset the fil_amount
      * -------------------------------------------------------------------------- */
     if (isNumber($amount_min) && isNumber($amount_max) && $amount_min > 0 && bccomp($amount_min, $amount_max, 2) == 0) {
         $fil_amount = $and . ' ( ';
         // Look in detail
         $fil_amount .= 'jr_grpt_id in ( select distinct j_grpt from jrnx where j_montant = ' . $amount_min . ') ';
         //and the total operation
         $fil_amount .= ' or ';
         $fil_amount .= ' jr_montant = ' . $amount_min;
         $fil_amount .= ')';
         $and = " and ";
     }
     // date
     if (isset($date_start) && isDate($date_start) != null) {
         $fil_date = $and . " jr_date >= to_date('" . $date_start . "','DD.MM.YYYY')";
         $and = " and ";
     }
     if (isset($date_end) && isDate($date_end) != null) {
         $fil_date .= $and . " jr_date <= to_date('" . $date_end . "','DD.MM.YYYY')";
         $and = " and ";
     }
     // date paiement
     if (isset($date_paid_start) && isDate($date_paid_start) != null) {
         $fil_date_paid = $and . " jr_date_paid >= to_date('" . $date_paid_start . "','DD.MM.YYYY')";
         $and = " and ";
     }
     if (isset($date_paid_end) && isDate($date_paid_end) != null) {
         $fil_date_paid .= $and . " jr_date_paid <= to_date('" . $date_paid_end . "','DD.MM.YYYY')";
         $and = " and ";
     }
     // comment
     if (isset($desc) && $desc != null) {
         $desc = sql_string($desc);
         $fil_desc = $and . " ( upper(jr_comment) like upper('%" . $desc . "%') or upper(jr_pj_number) like upper('%" . $desc . "%') " . " or upper(jr_internal)  like upper('%" . $desc . "%')\n                          or jr_grpt_id in (select j_grpt from jrnx where j_text ~* '" . $desc . "')\n                          or jr_id in (select jr_id from jrn_info where ji_value is not null and ji_value ~* '{$desc}')\n                          )";
         $and = " and ";
     }
     //    Poste
     if (isset($accounting) && $accounting != null) {
         $fil_account = $and . "  jr_grpt_id in (select j_grpt\n                         from jrnx where j_poste::text like '" . sql_string($accounting) . "%' )  ";
         $and = " and ";
     }
     // Quick Code
     if (isset($qcodesearch_op)) {
         $qcode = $qcodesearch_op;
     }
     if (isset($qcode) && $qcode != null) {
         $fil_qcode = $and . "  jr_grpt_id in ( select j_grpt from\n                       jrnx where trim(j_qcode) = upper(trim('" . sql_string($qcode) . "')))";
         $and = " and ";
     }
     // Only the unpaid
     if (isset($unpaid)) {
         $fil_paid = $and . SQL_LIST_UNPAID_INVOICE;
         $and = " and ";
     }
     $g_user = new User(new Database());
     $g_user->Check();
     $g_user->check_dossier(dossier::id());
     if ($g_user->admin == 0 && $g_user->is_local_admin() == 0) {
         $fil_sec = $and . " jr_def_id in ( select uj_jrn_id " . " from user_sec_jrn where " . " uj_login='******'g_user'] . "'" . " and uj_priv in ('R','W'))";
     }
     $where = $fil_ledger . $fil_amount . $fil_date . $fil_desc . $fil_sec . $fil_amount . $fil_qcode . $fil_paid . $fil_account . $fil_date_paid;
     $sql .= " where " . $where;
     return array($sql, $where);
 }
コード例 #17
0
 function operation_update_date_limit($p_text)
 {
     if (isDate($p_text) == null) {
         $p_text = null;
     }
     $sql = "update jrn set jr_ech=to_date(\$1,'DD.MM.YYYY') where jr_id=\$2";
     $this->db->exec_sql($sql, array($p_text, $this->jr_id));
 }
コード例 #18
0
 }
 /*
  * If something was entered in the URL box, it overrides any other URL
  * (even the url when the files is copied, or when the option is checked
  * to use the URL from the torrent's file name.)
  */
 if (isset($_POST["url"])) {
     if (strlen($_POST["url"]) > 0) {
         $url = $_POST["url"];
     }
 }
 /*
  * Check the dates to make sure they are legitimate dates.
  * If not, display a warning and don't add it to the database.
  */
 if (!isDate($removeurldate, true) || !isDate($hidetorrentdate, true)) {
     $statusMsg .= "ERROR: A date is invalid. Please use the format yyyy-mm-dd for dates (ie. '2004-03-24')";
 } else {
     /*
      * Trying to stay HTML compliant is a pain in the ass sometimes.
      */
     if (!get_magic_quotes_gpc()) {
         /*
          * PHP isn't adding slashes to the the POST results, so convert the strings
          * to HTML-compatible and run addslashes to be a compatible query
          * string
          */
         $filename = addslashes(htmlentities($filename));
         $url = addslashes(htmlentities($url));
         $threshold = addslashes(htmlentities($threshold));
         $strategy = addslashes(htmlentities($strategy));
コード例 #19
0
ファイル: order.html.php プロジェクト: soanni/stocks_oop
 $valid->isFloat('sumtotal');
 $valid->isFloat('brokerrevenue');
 $valid->isFloat('stopprice');
 $valid->isFloat('takeprice');
 $valid->removeTags('comment');
 $valid->noFilter('ordate');
 $valid->noFilter('ortype');
 $valid->noFilter('exchange');
 $valid->noFilter('company');
 $valid->noFilter('quote');
 $valid->noFilter('currency');
 //$valid->useEntities('comment');
 $validate = $valid->validateInput();
 $missing = $valid->getMissing();
 $errors = $valid->getErrors();
 if (!isDate($_POST['ordate'])) {
     $errors['ordate'] = "Invalid data supplied. Correct date format YYYY-mm-dd";
 }
 $insertOK = false;
 if (!$errors && !$missing) {
     $redirect = 'http://localhost/stocks_oop/dashboard/index.php';
     $stoploss = isset($_POST['stoploss']) ? 1 : 0;
     $takeprofit = isset($_POST['takeprofit']) ? 1 : 0;
     $sql = "INSERT INTO orders\r\n                        (ordate,\r\n                        ortype,\r\n                        brokerid,\r\n                        exchid,\r\n                        companyid,\r\n                        qid,\r\n                        amount,\r\n                        currencyid,\r\n                        price,\r\n                        stoploss,\r\n                        stopprice,\r\n                        takeprofit,\r\n                        takeprice,\r\n                        amountlot,\r\n                        total,\r\n                        brokerrevenue,\r\n                        orcomment,\r\n                        parentid,\r\n                        changedate,\r\n                        activeflag,\r\n                        accountid)\r\n                    VALUES\r\n                        (:ordate,\r\n                        :ortype,\r\n                        1,\r\n                        :exchid,\r\n                        :companyid,\r\n                        :qid,\r\n                        :amount,\r\n                        :currencyid,\r\n                        :price,\r\n                        :stoploss,\r\n                        :stopprice,\r\n                        :takeprofit,\r\n                        :takeprice,\r\n                        :amountlot,\r\n                        :total,\r\n                        :brokerrevenue,\r\n                        :orcomment,\r\n                        NULL,\r\n                        NOW(),\r\n                        1,\r\n                        1)";
     try {
         $stmt = $pdo->prepare($sql);
         $stmt->bindParam(':ordate', $_POST['ordate']);
         $stmt->bindParam(':ortype', $_POST['ortype']);
         $stmt->bindParam(':exchid', $_POST['exchange']);
         $stmt->bindParam(':companyid', $_POST['company']);
         $stmt->bindParam(':qid', $_POST['quote']);
コード例 #20
0
 }
 /* Show button  */
 echo '<h1 style="float:right;margin-right:20%"> Enregistrement </h1>';
 echo $Ledger->confirm($_POST, true);
 /* Show link for Invoice */
 if (isset($Ledger->doc)) {
     echo '<h2>Document </h2>';
     echo $Ledger->doc;
 }
 /* Save the additional information into jrn_info */
 $obj = new Acc_Ledger_Info($cn);
 $obj->save_extra($Ledger->jr_id, $_POST);
 // extourne
 if (isset($_POST['reverse_ck'])) {
     $p_date = HtmlInput::default_value_post('reverse_date', '');
     if (isDate($p_date) == $p_date) {
         // reverse the operation
         try {
             $Ledger->reverse($p_date);
             echo '<p>';
             echo _('Extourné au ') . $p_date;
             echo '</p>';
         } catch (Exception $e) {
             echo '<p class="notice">' . _('Opération non extournée') . $e->getMessage() . '</p>';
         }
     } else {
         // warning because date is invalid
         echo '<p class="notice">' . _('Date invalide, opération non extournée') . '</p>';
     }
 }
 echo $Ledger->button_new_operation();
コード例 #21
0
     $cond_poste .= ' pcm_val >= upper (\'' . Database::escape_string($from_poste->value) . '\')';
 }
 if ($to_poste->value != '') {
     if ($cond_poste == '') {
         $cond_poste = ' where pcm_val <= upper (\'' . Database::escape_string($to_poste->value) . '\')';
     } else {
         $cond_poste .= ' and pcm_val <= upper (\'' . Database::escape_string($to_poste->value) . '\')';
     }
 }
 $sql = $sql . $cond_poste . '  order by pcm_val::text';
 $a_poste = $cn->get_array($sql);
 if (sizeof($a_poste) == 0) {
     die("Nothing here. Strange.");
     exit;
 }
 if (isDate($_REQUEST['from_periode']) == null || isDate($_REQUEST['to_periode']) == null) {
     echo alert('Date malformée, désolée');
     return;
 }
 echo '<div class="content">';
 echo '<table class="result">';
 $l = isset($_REQUEST['letter']) ? 2 : 0;
 $s = isset($_REQUEST['solded']) ? 1 : 0;
 foreach ($a_poste as $poste_id) {
     $Poste = new Acc_Account_Ledger($cn, $poste_id['pcm_val']);
     $Poste->load();
     $Poste->get_row_date($_GET['from_periode'], $_GET['to_periode'], $l, $s);
     if (empty($Poste->row)) {
         continue;
     }
     echo '<tr >
コード例 #22
0
ファイル: ajax_misc.php プロジェクト: Kloadut/noalyss_ynh
 // start date
 $start = new IDate('search_start');
 /*  check if date are valid */
 if (isset($search_start) && isDate($search_start) == null) {
     ob_start();
     alert(_('Date malformée'));
     $date_error = ob_get_contents();
     ob_end_clean();
     $search_start = $first_per->first_day();
 }
 $start->value = isset($search_start) ? $search_start : $first_per->first_day();
 $line = td('Date Debut') . td($start->input());
 // end date
 $end = new IDate('search_end');
 /*  check if date are valid */
 if (isset($search_end) && isDate($search_end) == null) {
     ob_start();
     alert(_('Date malformée'));
     $date_error = ob_get_contents();
     ob_end_clean();
     $search_end = $last_per->last_day();
 }
 $end->value = isset($search_end) ? $search_end : $last_per->last_day();
 $line .= td(_('Date Fin')) . td($end->input());
 $r .= tr($line);
 // Side
 $line = td(_('Debit / Credit'));
 $iside = new ISelect('side');
 $iside->value = array(array('label' => _('Debit'), 'value' => 0), array('label' => _('Credit'), 'value' => 1), array('label' => _('Les 2'), 'value' => 3));
 /**
  *
コード例 #23
0
ファイル: fiche.inc.php プロジェクト: Kloadut/noalyss_ynh
$export_pdf .= '</FORM>';
$export_print = HtmlInput::print_window();
$export_csv = '<FORM METHOD="get" ACTION="export.php" style="display:inline">';
$export_csv .= HtmlInput::hidden('cat', $_GET['cat']);
$export_csv .= HtmlInput::hidden('act', 'CSV:fiche_balance');
$export_csv .= HtmlInput::hidden('start', $_GET['start']);
$export_csv .= HtmlInput::hidden('end', $_GET['end']);
$export_csv .= HtmlInput::hidden('histo', $_GET['histo']);
$export_csv .= HtmlInput::request_to_hidden(array('allcard'));
$export_csv .= dossier::hidden();
$export_csv .= HtmlInput::submit('CSV', 'Export en CSV');
$export_csv .= '</FORM>';
/*
 * Date is important is requested balance
 */
if (isDate($_REQUEST['start']) == null || isDate($_REQUEST['end']) == null) {
    echo h2('Date invalide !', 'class="error"');
    alert('Date invalide !');
    return;
}
/*************************************************************************************************************************
 * Balance agée tous
/*************************************************************************************************************************/
if ($_GET['histo'] == 6) {
    require_once NOALYSS_INCLUDE . '/class_balance_age.php';
    $bal = new Balance_Age($cn);
    $export_csv = '<FORM METHOD="get" ACTION="export.php" style="display:inline">';
    $export_csv .= HtmlInput::request_to_hidden(array('gDossier', 'ac', 'p_let', 'p_date_start'));
    $export_csv .= HtmlInput::hidden('p_date_start', $_GET['start']);
    $export_csv .= HtmlInput::hidden('act', 'CSV:balance_age');
    $export_csv .= HtmlInput::hidden('p_let', 'let');
コード例 #24
0
ファイル: validate.php プロジェクト: robertvines/JG-Wentworth
function valDate($date, $req = false)
{
    if ($req == TRUE && $date == NULL) {
        echo "Error: date field is missing";
        exit;
    } else {
        //***************************************************************************
        // Checks format of date
        if (!checkFormat($date)) {
            echo "Error: incorrect format<br>All dates should match YYYY-MM-DD";
            exit;
        }
        //end inner if
        //***************************************************************************
        // Checks for a valid date
        if (!isDate($date)) {
            echo "Error: invalid date";
            exit;
        }
        //end inner if
        //***************************************************************************
        // Checks if date is either in the past or today
        if (!isBeforeTom($date)) {
            echo "Error: invalid date range";
            exit;
        } else {
            $date = trim($date);
            return $date;
        }
        //end inner if
    }
    //end outer if
}
コード例 #25
0
ファイル: api_users.php プロジェクト: Eun/developer
     $cityn = $what['cityn'];
 }
 if (isset($data['street']) and names($data['street'], 50)) {
     $what['street'] = names($data['street'], 50);
     $street = $what['street'];
 }
 if (isset($data['streetn']) and wpreg_check($data['streetn'], 6)) {
     $what['streetn'] = wpreg_check($data['streetn'], 6);
     $streetn = $what['streetn'];
 }
 if (isset($data['salutation']) and is_number($data['salutation'], 1)) {
     $what['salutation'] = is_number($data['salutation'], 1);
     $salutation = $what['salutation'];
 }
 if (isset($data['birthday']) and isDate($data['birthday'])) {
     $what['birthday'] = date('Y-m-d', strtotime(isDate($data['birthday'])));
     $birthday = $what['birthday'];
 }
 if (isset($data['country']) and wpreg_check($data['country'], 2)) {
     $what['country'] = wpreg_check(strtolower($data['country']), 2);
     $country = $what['country'];
 }
 if (isset($data['mail_backup']) and active_check($data['mail_backup'])) {
     $what['mail_backup'] = $data['mail_backup'];
     $mail_backup = $what['mail_backup'];
 }
 if (isset($data['mail_gsupdate']) and active_check($data['mail_gsupdate'])) {
     $what['mail_gsupdate'] = $data['mail_gsupdate'];
     $mail_gsupdate = $what['mail_gsupdate'];
 }
 if (isset($data['mail_securitybreach']) and active_check($data['mail_securitybreach'])) {
コード例 #26
0
ファイル: getOriginalHTML.php プロジェクト: hunkim/assembly
function process($db, $file)
{
    $content = file_get_contents($file);
    $txt = strip_tags($content);
    $txt = iconv('EUC-KR', 'UTF-8', $content);
    $tokens = preg_split('/\\s+/', $txt);
    $billArr = [];
    $bill = false;
    $title = "";
    foreach ($tokens as $line) {
        if (startsWith($line, 'href="javascript:GoDetail(')) {
            if ($bill) {
                // Do something with bill
                echo $bill->toString() . "\n";
                storeContent($db, $bill);
            }
            $id = parseBillId($line);
            $bill = new Bill($id);
            continue;
        }
        if (!$bill) {
            continue;
        }
        if (isDate($line)) {
            if (!$bill->proposed) {
                $bill->proposed = $line;
            } else {
                if (!$bill->processed) {
                    $bill->processed = $line;
                }
            }
            continue;
        }
        if (startsWith($line, 'title="')) {
            $title .= $line;
            continue;
        }
        if ($title != "") {
            $title .= $line;
        }
        if (strpos($line, ')">') !== false) {
            $arr = explode('"', $title);
            if (count($arr) > 2) {
                $bill->titleHTML = $arr[1];
            }
            $title = "";
        }
        switch ($line) {
            case '부결':
            case '철회':
            case '대안반영폐기':
            case '수정가결':
            case '원안가결':
                $bill->result = $line;
                break;
            case '위원장':
            case '의원':
            case '정부':
                $bill->proposedby = $line;
                break;
            case '공포':
            case '본회의의결':
        }
    }
    // Add the last if there.
    if ($bill) {
        // Do something with bill
        echo $bill->toString() . "\n";
        storeContent($db, $bill);
    }
}
コード例 #27
0
 function record_save($p_array)
 {
     global $cn;
     try {
         if (isDate($p_array['p_date']) == null) {
             throw new Exception('Date invalide');
         }
         $cn->start();
         $ch = new Stock_Change_Sql($cn);
         $ch->setp("c_comment", $p_array['p_motif']);
         $ch->setp("r_id", $p_array['p_depot']);
         $ch->setp("c_date", $p_array['p_date']);
         $ch->setp('tech_user', $_SESSION['g_user']);
         $ch->insert();
         $per = new Periode($cn);
         $periode = $per->find_periode($p_array['p_date']);
         $exercice = $per->get_exercice($periode);
         $nb = $p_array['row'];
         for ($i = 0; $i < $nb; $i++) {
             $a = new Stock_Goods_Sql($cn);
             if ($p_array['sg_quantity' . $i] != 0 && trim($p_array['sg_code' . $i]) != '') {
                 $stock = strtoupper(trim($p_array['sg_code' . $i]));
                 $fiche = new Fiche($cn);
                 $fiche->get_by_qcode($p_array['sg_code' . $i]);
                 /*
                  * check if code stock does exist
                  */
                 $count = $cn->get_value('select count(*) from fiche_detail where ad_id=$1 and ad_value=$2', array(ATTR_DEF_STOCK, $stock));
                 if ($count == 0) {
                     throw new Exception("Code stock inexistant");
                 }
                 $a->f_id = $fiche->id;
                 $a->sg_code = $stock;
                 $a->sg_quantity = abs($p_array['sg_quantity' . $i]);
                 $a->sg_type = $p_array['sg_quantity' . $i] > 0 ? 'd' : 'c';
                 $a->sg_comment = $p_array['p_motif'];
                 $a->tech_user = $_SESSION['g_user'];
                 $a->r_id = $p_array['p_depot'];
                 $a->sg_exercice = $exercice;
                 $a->c_id = $ch->c_id;
                 $a->sg_date = $p_array['p_date'];
                 $a->insert();
             }
         }
         $cn->commit();
     } catch (Exception $exc) {
         echo $exc->getTraceAsString();
         throw $exc;
     }
 }
コード例 #28
0
echo '</FORM>';
echo '</div>';
//if (! isset($_REQUEST['seek'])) exit;
echo '<hr>';
//--------------------------------------------------------------------------------
// record the data
//--------------------------------------------------------------------------------
if (isset($_POST['record'])) {
    $letter = new Lettering_Account($cn);
    $letter->save($_POST);
}
//--------------------------------------------------------------------------------
// Show the result
//--------------------------------------------------------------------------------
if (isset($_GET['start']) && isset($_GET['end'])) {
    if (isDate($_GET['start']) == null || isDate($_GET['end']) == null) {
        echo alert(_('Date malformée, désolé'));
        return;
    }
}
echo '<div id="list">';
$fiche = new Fiche($cn, $_REQUEST['f_id']);
$quick_code = $fiche->get_quick_code();
$letter = new Lettering_Card($cn);
$letter->set_parameter('quick_code', $quick_code);
$letter->set_parameter('start', $start->value);
$letter->set_parameter('end', $end->value);
if ($sel->selected == 0) {
    echo $letter->show_list('all');
}
if ($sel->selected == 1) {
コード例 #29
0
 /**
  *@brief create a string to filter thanks the date
  *@return a sql string like jr_date > ... and jr_date < ....
  *@note use the data member start_day and end_day
  *@see get_reconciled get_not_reconciled
  */
 function filter_date()
 {
     global $g_user;
     list($start, $end) = $g_user->get_limit_current_exercice();
     if (isDate($this->start_day) == null) {
         $this->start_day = $start;
     }
     if (isDate($this->end_day) == null) {
         $this->end_day = $end;
     }
     $sql = " (jr_date >= to_date('" . $this->start_day . "','DD.MM.YYYY')\n\t\tand jr_date <= to_date('" . $this->end_day . "','DD.MM.YYYY'))";
     return $sql;
 }
コード例 #30
0
 public function verify($p_array)
 {
     global $g_parameter, $g_user;
     if (is_array($p_array) == false || empty($p_array)) {
         throw new Exception("Array empty");
     }
     extract($p_array);
     /*
      * Check needed value
      */
     check_parameter($p_array, 'p_jrn,e_date,e_client');
     /* check for a double reload */
     if (isset($mt) && $this->db->count_sql('select jr_mt from jrn where jr_mt=$1', array($mt)) != 0) {
         throw new Exception(_('Double Encodage'), 5);
     }
     /* check if we can write into this ledger */
     if ($g_user->check_jrn($p_jrn) != 'W') {
         throw new Exception(_('Accès interdit'), 20);
     }
     /* check if there is a customer */
     if (strlen(trim($e_client)) == 0) {
         throw new Exception(_('Vous n\'avez pas donné de client'), 11);
     }
     /*  check if the date is valid */
     if (isDate($e_date) == null) {
         throw new Exception(_('Date invalide'), 2);
     }
     $oPeriode = new Periode($this->db);
     if ($this->check_periode() == true) {
         $tperiode = $period;
         /* check that the datum is in the choosen periode */
         $oPeriode->p_id = $period;
         list($min, $max) = $oPeriode->get_date_limit();
         if (cmpDate($e_date, $min) < 0 || cmpDate($e_date, $max) > 0) {
             throw new Exception(_('Date et periode ne correspondent pas'), 6);
         }
     } else {
         $per = new Periode($this->db);
         $tperiode = $per->find_periode($e_date);
     }
     /* check if the periode is closed */
     if ($this->is_closed($tperiode) == 1) {
         throw new Exception(_('Periode fermee'), 6);
     }
     /* check if we are using the strict mode */
     if ($this->check_strict() == true) {
         /* if we use the strict mode, we get the date of the last
            operation */
         $last_date = $this->get_last_date();
         if ($last_date != null && cmpDate($e_date, $last_date) < 0) {
             throw new Exception(_('Vous utilisez le mode strict la dernière operation est date du ') . $last_date . _(' vous ne pouvez pas encoder à une date antérieure'), 13);
         }
     }
     $fiche = new Fiche($this->db);
     $fiche->get_by_qcode($e_client);
     if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) {
         throw new Exception(_('La fiche ') . $e_client . _('n\'a pas de poste comptable'), 8);
     }
     /* get the account and explode if necessary */
     $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
     // if 2 accounts, take only the debit one for customer
     if (strpos($sposte, ',') != 0) {
         $array = explode(',', $sposte);
         $poste_val = $array[0];
     } else {
         $poste_val = $sposte;
     }
     /* The account exists */
     $poste = new Acc_Account_Ledger($this->db, $poste_val);
     if ($poste->load() == false) {
         throw new Exception(_('Pour la fiche ') . $e_client . _(' le poste comptable [') . $poste->id . _('] n\'existe pas'), 9);
     }
     /* Check if the card belong to the ledger */
     $fiche = new Fiche($this->db);
     $fiche->get_by_qcode($e_client, 'deb');
     if ($fiche->belong_ledger($p_jrn) != 1) {
         throw new Exception(_('La fiche ') . $e_client . _('n\'est pas accessible à ce journal'), 10);
     }
     $nb = 0;
     //----------------------------------------
     // foreach item
     //----------------------------------------
     for ($i = 0; $i < $nb_item; $i++) {
         if (strlen(trim(${'e_march' . $i})) == 0) {
             continue;
         }
         /* check if amount are numeric and */
         if (isNumber(${'e_march' . $i . '_price'}) == 0) {
             throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a un montant invalide [') . ${'e_march' . $i} . ']', 6);
         }
         if (isNumber(${'e_quant' . $i}) == 0) {
             throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a une quantité invalide [') . ${'e_quant' . $i} . ']', 7);
         }
         /* check if all card has a ATTR_DEF_ACCOUNT */
         $fiche = new Fiche($this->db);
         $fiche->get_by_qcode(${'e_march' . $i});
         if ($fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true) {
             throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('n\'a pas de poste comptable'), 8);
         }
         // Check if the given tva id is valid
         if ($g_parameter->MY_TVA_USE == 'Y') {
             if (isNumber(${'e_march' . $i . '_tva_id'}) == 0) {
                 throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a un code tva invalide') . ' [' . ${'e_march' . $i . '_tva_id'} . ']', 13);
             }
             $tva_rate = new Acc_Tva($this->db);
             $tva_rate->set_parameter('id', ${'e_march' . $i . '_tva_id'});
             if ($tva_rate->load() != 0) {
                 throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('a un code tva invalide') . ' [' . ${'e_march' . $i . '_tva_id'} . ']', 13);
             }
             /*
              * check if the accounting for VAT are valid
              */
             $a_poste = explode(',', $tva_rate->tva_poste);
             if ($this->db->get_value('select count(*) from tmp_pcmn where pcm_val=$1', array($a_poste[0])) == 0 || $this->db->get_value('select count(*) from tmp_pcmn where pcm_val=$1', array($a_poste[1])) == 0) {
                 throw new Exception(_(" La TVA " . $tva_rate->tva_label . " utilise des postes comptables inexistants"));
             }
         }
         // if 2 accounts, take only the credit one
         /* The account exists */
         $sposte = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
         if (strpos($sposte, ',') != 0) {
             $array = explode(',', $sposte);
             $poste_val = $array[1];
         } else {
             $poste_val = $sposte;
         }
         $poste = new Acc_Account_Ledger($this->db, $poste_val);
         if ($poste->load() == false) {
             throw new Exception(_('Pour la fiche ') . ${'e_march' . $i} . _(' le poste comptable [') . $poste->id . _('n\'existe pas'), 9);
         }
         /* Check if the card belong to the ledger */
         $fiche = new Fiche($this->db);
         $fiche->get_by_qcode(${'e_march' . $i});
         if ($fiche->belong_ledger($p_jrn, 'cred') != 1) {
             throw new Exception(_('La fiche ') . ${'e_march' . $i} . _('n\'est pas accessible à ce journal'), 10);
         }
         $nb++;
     }
     if ($nb == 0) {
         throw new Exception(_('Il n\'y a aucune marchandise'), 12);
     }
     //------------------------------------------------------
     // The "Paid By"  check
     //------------------------------------------------------
     if ($e_mp != 0) {
         $this->check_payment($e_mp, ${"e_mp_qcode_" . $e_mp});
     }
 }