function get_array_card($p_type, $p_extra = "")
 {
     switch ($p_type) {
         case 'X':
             $this->afiche = $this->cn->get_array("\n            with m as (select distinct qp_supplier as f_id from quant_purchase union select qs_client from quant_sold)\n            select distinct fiche.f_id as f_id ,f1.ad_value as name, f3.ad_value as first_name,f2.ad_value  as quick_code  \n                from fiche \n                    join m on (fiche.f_id=m.f_id)\n                    join fiche_detail as f1 on (fiche.f_id=f1.f_id and f1.ad_id=1) \n                    join fiche_detail as f2 on (fiche.f_id=f2.f_id and f2.ad_id=23) \n                    left join fiche_detail as f3 on (fiche.f_id=f3.f_id and f3.ad_id=32)\n                 where \n                 fiche.fd_id=\$1\n                 order by f1.ad_value\n                 ", array($p_extra));
             break;
         case 'U':
             $fiche = new Fiche($this->cn, $p_extra);
             $this->afiche[0]['f_id'] = $fiche->id;
             $this->afiche[0]['quick_code'] = $fiche->get_quick_code();
             $this->afiche[0]['name'] = $fiche->strAttribut(ATTR_DEF_NAME, 0);
             $this->afiche[0]['first_name'] = $fiche->strAttribut(ATTR_DEF_FIRST_NAME, 0);
             break;
         case 'F':
             $this->afiche = $this->cn->get_array("\n            select distinct qp_supplier as f_id ,f1.ad_value as name, f3.ad_value as first_name,f2.ad_value  as quick_code  \n                from quant_purchase join \n                    fiche_detail as f1 on (qp_supplier=f1.f_id and f1.ad_id=1) \n                    join fiche_detail as f2 on (qp_supplier=f2.f_id and f2.ad_id=23) \n                    left join fiche_detail as f3 on (qp_supplier=f3.f_id and f3.ad_id=32)\n                 order by f1.ad_value\n                 ");
             break;
         case 'C':
             $this->afiche = $this->cn->get_array("\n             select distinct qs_client as f_id ,f1.ad_value as name, f3.ad_value as first_name,f2.ad_value  as quick_code  \n                from quant_sold join \n                    fiche_detail as f1 on (qs_client=f1.f_id and f1.ad_id=1) \n                    join fiche_detail as f2 on (qs_client=f2.f_id and f2.ad_id=23) \n                    left join fiche_detail as f3 on (qs_client=f3.f_id and f3.ad_id=32)\n                 order by f1.ad_value\n                 ");
             break;
         default:
             throw new Exception('Type invalide');
     }
 }
 /**
  * @brief check if the payment method is valid
  * @param$e_mp is the value and $e_mp_qcode is the quickcode
  * \return nothing throw an Exception
  */
 public function check_payment($e_mp, $e_mp_qcode)
 {
     /*   Check if the "paid by" is empty, */
     if ($e_mp != 0) {
         /* the paid by is not empty then check if valid */
         $empl = new Fiche($this->db);
         $empl->get_by_qcode($e_mp_qcode);
         if ($empl->empty_attribute(ATTR_DEF_ACCOUNT) == true) {
             throw new Exception(_("Celui qui paie n' a pas de poste comptable"), 20);
         }
         /* get the account and explode if necessary */
         $sposte = $empl->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;
         }
         $poste = new Acc_Account_Ledger($this->db, $poste_val);
         if ($poste->load() == false) {
             throw new Exception(sprintf(_("Pour la fiche %s le poste comptable [%s] n'existe pas"), $empl->quick_code, $poste->id), 9);
         }
     }
 }
Beispiel #3
0
    function Summary($p_search = "", $p_action = "", $p_sql = "", $p_nothing = false)
    {
        $p_search = sql_string($p_search);
        $extra_sql = "";
        if ($this->company != "") {
            $extra_sql = "and f_id in (select f_id from fiche_detail\n                       where ad_value=upper('" . $this->company . "') and ad_id=" . ATTR_DEF_COMPANY . ") ";
        }
        $url = urlencode($_SERVER['REQUEST_URI']);
        $script = $_SERVER['PHP_SELF'];
        // Creation of the nav bar
        // Get the max numberRow
        $all_contact = $this->count_by_modele($this->fiche_def_ref, $p_search, $extra_sql);
        // Get offset and page variable
        $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
        $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
        $bar = navigation_bar($offset, $all_contact, $_SESSION['g_pagesize'], $page);
        // set a filter ?
        $search = "";
        if (trim($p_search) != "") {
            $search = " and f_id in\n                    (select f_id from fiche_Detail\n                    where\n                    ad_id=1 and ad_value ~* '{$p_search}') ";
        }
        // Get The result Array
        $step_contact = $this->get_by_category($offset, $search . $extra_sql . $p_sql);
        if ($all_contact == 0) {
            return "";
        }
        $r = $bar;
        $r .= '<table id="contact_tb" class="sortable">
            <TR>
            <th>Quick Code</th>
            <th>Nom</th>
            <th>Prénom</th>
			<th>Société</th>
            <th>Téléphone</th>
            <th>email</th>
            <th>Fax</th>
            </TR>';
        $base = $_SERVER['PHP_SELF'];
        // Compute the url
        $url = "";
        $and = "?";
        $get = $_GET;
        if (isset($get)) {
            foreach ($get as $name => $value) {
                // we clean the parameter offset, step, page and size
                if (!in_array($name, array('f_id', 'detail'))) {
                    $url .= $and . $name . "=" . $value;
                    $and = "&";
                }
                // if
            }
            //foreach
        }
        // if
        $back_url = urlencode($_SERVER['REQUEST_URI']);
        if (sizeof($step_contact) == 0) {
            return $r;
        }
        $idx = 0;
        foreach ($step_contact as $contact) {
            $l_company = new Fiche($this->cn);
            $l_company->get_by_qcode($contact->strAttribut(ATTR_DEF_COMPANY), false);
            $l_company_name = $l_company->strAttribut(ATTR_DEF_NAME);
            if ($l_company_name == NOTFOUND) {
                $l_company_name = "";
            }
            // add popup for detail
            if ($l_company_name != "") {
                $l_company_name = HtmlInput::card_detail($contact->strAttribut(ATTR_DEF_COMPANY), $l_company_name, 'style="text-decoration:underline;"');
            }
            $tr = $idx % 2 == 0 ? ' <tr class="odd">' : '<tr class="even">';
            $idx++;
            $r .= $tr;
            $qcode = $contact->strAttribut(ATTR_DEF_QUICKCODE);
            $r .= '<TD>' . HtmlInput::card_detail($qcode) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_NAME) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_FIRST_NAME) . "</TD>";
            $r .= "<TD>" . $l_company_name . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_TEL) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_EMAIL) . "</TD>" . "<TD> " . $contact->strAttribut(ATTR_DEF_FAX) . "</TD>";
            $r .= "</TR>";
        }
        $r .= "</TABLE>";
        $r .= $bar;
        return $r;
    }
 /**
  * return a string with the bank account, name and quick_code
  */
 function get_bank_name()
 {
     $this->bank_id = $this->db->get_value('select jrn_def_bank from jrn_def where jrn_def_id=$1', array($this->id));
     $fBank = new Fiche($this->db, $this->bank_id);
     $e_bank_account = " : " . $fBank->strAttribut(ATTR_DEF_BQ_NO);
     $e_bank_name = " : " . $fBank->strAttribut(ATTR_DEF_NAME);
     $e_bank_qcode = ": " . $fBank->strAttribut(ATTR_DEF_QUICKCODE);
     return $e_bank_qcode . $e_bank_name . $e_bank_account;
 }
    echo th(_('Total'), 'style="text-align:right"');
}
if ($owner->MY_ANALYTIC != 'nu') {
    $anc = new Anc_Plan($cn);
    $a_anc = $anc->get_list(' order by pa_id ');
    $x = count($a_anc);
    /* set the width of the col */
    /* add hidden variables pa[] to hold the value of pa_id */
    $str_anc .= '<tr><th>Code</th><th>Montant</th><th colspan="' . $x . '">' . _('Compt. Analytique') . Anc_Plan::hidden($a_anc) . '</th></tr>';
}
echo '</tr>';
for ($e = 0; $e < count($obj->det->array); $e++) {
    $row = '';
    $q = $obj->det->array[$e];
    $fiche = new Fiche($cn, $q['qp_fiche']);
    $qcode = $fiche->strAttribut(ATTR_DEF_QUICKCODE);
    $view_card_detail = HtmlInput::card_detail($qcode, "", ' class="line" ');
    $row = td($view_card_detail);
    $sym_tva = '';
    if ($owner->MY_TVA_USE == 'Y' && $q['qp_vat_code'] != '') {
        /* retrieve TVA symbol */
        $tva = new Acc_Tva($cn, $q['qp_vat_code']);
        $tva->load();
        $sym_tva = h($tva->get_parameter('label'));
    }
    if ($owner->MY_UPDLAB == 'Y') {
        $l_lib = $q['j_text'] == '' ? $fiche->strAttribut(ATTR_DEF_NAME) : $q['j_text'];
        $hidden = HtmlInput::hidden("j_id[]", $q['j_id']);
        $input = new IText("e_march" . $q['j_id'] . "_label", $l_lib);
        $input->css_size = "100%";
    } else {
}
?>
</tr>
<?php 
$e = 0;
foreach ($array as $row) {
    $e++;
    if ($e % 2 == 0) {
        echo '<tr class="odd">';
    } else {
        echo '<tr class="even">';
    }
    $fiche = new Fiche($cn);
    $fiche->id = $row['f_id'];
    $fiche->getAttribut();
    $detail = HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE));
    echo td($detail);
    foreach ($fiche->attribut as $attr) {
        $sort = "";
        if ($attr->ad_type != 'select') {
            if ($attr->ad_type == "date") {
                // format YYYYMMDD
                $sort = 'sorttable_customkey="' . format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD") . '"';
            }
            echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" ' . $sort);
        } else {
            $value = $cn->make_array($attr->ad_extra);
            $row_content = "";
            for ($e = 0; $e < count($value); $e++) {
                if ($value[$e]['value'] == $attr->av_text) {
                    $row_content = h($value[$e]['label']);
Beispiel #7
0
 function Replace($p_tag, $p_array)
 {
     global $g_parameter;
     $p_tag = strtoupper($p_tag);
     $p_tag = str_replace('=', '', $p_tag);
     $r = "Tag inconnu";
     switch ($p_tag) {
         case 'DATE':
             $r = isset($p_array['ag_timestamp']) ? $p_array['ag_timestamp'] : $p_array['e_date'];
             break;
         case 'DATE_CALC':
             $r = ' Date inconnue ';
             // Date are in $p_array['ag_date']
             // or $p_array['e_date']
             if (isset($p_array['ag_timestamp'])) {
                 $date = format_date($p_array['ag_timestamp'], 'DD.MM.YYYY', 'YYYY-MM-DD');
                 $r = $date;
             }
             if (isset($p_array['e_date'])) {
                 $date = format_date($p_array['e_date'], 'DD.MM.YYYY', 'YYYY-MM-DD');
                 $r = $date;
             }
             break;
             //
             //  the company priv
         //
         //  the company priv
         case 'MY_NAME':
             $r = $g_parameter->MY_NAME;
             break;
         case 'MY_CP':
             $r = $g_parameter->MY_CP;
             break;
         case 'MY_COMMUNE':
             $r = $g_parameter->MY_COMMUNE;
             break;
         case 'MY_TVA':
             $r = $g_parameter->MY_TVA;
             break;
         case 'MY_STREET':
             $r = $g_parameter->MY_STREET;
             break;
         case 'MY_NUMBER':
             $r = $g_parameter->MY_NUMBER;
             break;
         case 'MY_TEL':
             $r = $g_parameter->MY_TEL;
             break;
         case 'MY_FAX':
             $r = $g_parameter->MY_FAX;
             break;
         case 'MY_PAYS':
             $r = $g_parameter->MY_PAYS;
             break;
             // customer
             /*\note The CUST_* are retrieved thx the $p_array['tiers']
              * which contains the quick_code
              */
         // customer
         /*\note The CUST_* are retrieved thx the $p_array['tiers']
          * which contains the quick_code
          */
         case 'SOLDE':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $p = $tiers->strAttribut(ATTR_DEF_ACCOUNT);
             $poste = new Acc_Account_Ledger($this->db, $p);
             $r = $poste->get_solde(' true');
             break;
         case 'CUST_NAME':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_NAME);
             break;
         case 'CUST_ADDR_1':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_ADRESS);
             break;
         case 'CUST_CP':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_CP);
             break;
         case 'CUST_CITY':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_CITY);
             break;
         case 'CUST_CO':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_PAYS);
             break;
             // Marchandise in $p_array['e_march*']
             // \see user_form_achat.php or user_form_ven.php
         // Marchandise in $p_array['e_march*']
         // \see user_form_achat.php or user_form_ven.php
         case 'CUST_VAT':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_NUMTVA);
             break;
         case 'CUST_NUM':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER);
             break;
         case 'CUST_BANQUE_NO':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_BQ_NO);
             break;
         case 'CUST_BANQUE_NAME':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_BQ_NAME);
             break;
             /* -------------------------------------------------------------------------------- */
             /* BENEFIT (fee notes */
         /* -------------------------------------------------------------------------------- */
         /* BENEFIT (fee notes */
         case 'BENEF_NAME':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_NAME);
             break;
         case 'BENEF_ADDR_1':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_ADRESS);
             break;
         case 'BENEF_CP':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_CP);
             break;
         case 'BENEF_CITY':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_CITY);
             break;
         case 'BENEF_CO':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_PAYS);
             break;
             // Marchandise in $p_array['e_march*']
             // \see user_form_achat.php or user_form_ven.php
         // Marchandise in $p_array['e_march*']
         // \see user_form_achat.php or user_form_ven.php
         case 'BENEF_VAT':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_NUMTVA);
             break;
         case 'BENEF_NUM':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER);
             break;
         case 'BENEF_BANQUE_NO':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_BQ_NO);
             break;
         case 'BENEF_BANQUE_NAME':
             $tiers = new Fiche($this->db);
             $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
             if ($qcode == '') {
                 $r = '';
                 break;
             }
             $tiers->get_by_qcode($qcode, false);
             $r = $tiers->strAttribut(ATTR_DEF_BQ_NAME);
             break;
             // Marchandise in $p_array['e_march*']
             // \see user_form_achat.php or user_form_ven.php
         // Marchandise in $p_array['e_march*']
         // \see user_form_achat.php or user_form_ven.php
         case 'NUMBER':
             $r = $this->d_number;
             break;
         case 'USER':
             return $_SESSION['use_name'] . ', ' . $_SESSION['use_first_name'];
             break;
         case 'REFERENCE':
             $act = new Follow_Up($this->db);
             $act->ag_id = $this->ag_id;
             $act->get();
             $r = $act->ag_ref;
             break;
             /*
              *  - [VEN_ART_NAME]
              *  - [VEN_ART_PRICE]
              *  - [VEN_ART_QUANT]
              *  - [VEN_ART_TVA_CODE]
              *  - [VEN_ART_STOCK_CODE]
              *  - [VEN_HTVA]
              *  - [VEN_TVAC]
              *  - [VEN_TVA]
              *  - [TOTAL_VEN_HTVA]
              *  - [DATE_LIMIT]
              */
         /*
          *  - [VEN_ART_NAME]
          *  - [VEN_ART_PRICE]
          *  - [VEN_ART_QUANT]
          *  - [VEN_ART_TVA_CODE]
          *  - [VEN_ART_STOCK_CODE]
          *  - [VEN_HTVA]
          *  - [VEN_TVAC]
          *  - [VEN_TVA]
          *  - [TOTAL_VEN_HTVA]
          *  - [DATE_LIMIT]
          */
         case 'DATE_LIMIT_CALC':
             extract($p_array);
             $id = 'e_ech';
             if (!isset(${$id})) {
                 return "";
             }
             $r = format_date(${$id}, 'DD.MM.YYYY', 'YYYY-MM-DD');
             break;
         case 'DATE_LIMIT':
             extract($p_array);
             $id = 'e_ech';
             if (!isset(${$id})) {
                 return "";
             }
             $r = ${$id};
             break;
         case 'MARCH_NEXT':
             $this->counter++;
             $r = '';
             break;
         case 'VEN_ART_NAME':
             extract($p_array);
             $id = 'e_march' . $this->counter;
             // check if the march exists
             if (!isset(${$id})) {
                 return "";
             }
             // check that something is sold
             if (${'e_march' . $this->counter . '_price'} != 0 && ${'e_quant' . $this->counter} != 0) {
                 $f = new Fiche($this->db);
                 $f->get_by_qcode(${$id}, false);
                 $r = $f->strAttribut(ATTR_DEF_NAME);
             } else {
                 $r = "";
             }
             break;
         case 'VEN_ART_LABEL':
             extract($p_array);
             $id = 'e_march' . $this->counter . "_label";
             // check if the march exists
             if (!isset(${$id}) || isset(${$id}) && strlen(trim(${$id})) == 0) {
                 $id = 'e_march' . $this->counter;
                 // check if the march exists
                 if (!isset(${$id})) {
                     $r = "";
                 } else {
                     // check that something is sold
                     if (${'e_march' . $this->counter . '_price'} != 0 && ${'e_quant' . $this->counter} != 0) {
                         $f = new Fiche($this->db);
                         $f->get_by_qcode(${$id}, false);
                         $r = $f->strAttribut(ATTR_DEF_NAME);
                     } else {
                         $r = "";
                     }
                 }
             } else {
                 $r = ${'e_march' . $this->counter . '_label'};
             }
             break;
         case 'VEN_ART_STOCK_CODE':
             extract($p_array);
             $id = 'e_march' . $this->counter;
             // check if the march exists
             if (!isset(${$id})) {
                 $r = "";
             } else {
                 // check that something is sold
                 if (${'e_march' . $this->counter . '_price'} != 0 && ${'e_quant' . $this->counter} != 0) {
                     $f = new Fiche($this->db);
                     $f->get_by_qcode(${$id}, false);
                     $r = $f->strAttribut(ATTR_DEF_STOCK);
                     $r = $r == NOTFOUND ? '' : $r;
                 }
             }
             break;
         case 'VEN_ART_PRICE':
             extract($p_array);
             $id = 'e_march' . $this->counter . '_price';
             if (!isset(${$id})) {
                 return "";
             }
             if (${$id} == 0) {
                 return "";
             }
             $r = ${$id};
             break;
         case 'TVA_RATE':
         case 'VEN_ART_TVA_RATE':
             extract($p_array);
             $id = 'e_march' . $this->counter . '_tva_id';
             if (!isset(${$id})) {
                 return "";
             }
             if (${$id} == -1 || ${$id} == '') {
                 return "";
             }
             $march_id = 'e_march' . $this->counter . '_price';
             if (!isset(${$march_id})) {
                 return '';
             }
             $tva = new Acc_Tva($this->db);
             $tva->set_parameter("id", ${$id});
             if ($tva->load() == -1) {
                 return '';
             }
             return $tva->get_parameter("rate");
             break;
         case 'TVA_CODE':
         case 'VEN_ART_TVA_CODE':
             extract($p_array);
             $id = 'e_march' . $this->counter . '_tva_id';
             if (!isset(${$id})) {
                 return "";
             }
             if (${$id} == -1) {
                 return "";
             }
             $qt = 'e_quant' . $this->counter;
             $price = 'e_march' . $this->counter . '_price';
             if (${$price} == 0 || ${$qt} == 0 || strlen(trim($price)) == 0 || strlen(trim($qt)) == 0) {
                 return "";
             }
             $r = ${$id};
             break;
         case 'TVA_LABEL':
             extract($p_array);
             $id = 'e_march' . $this->counter . '_tva_id';
             if (!isset(${$id})) {
                 return "";
             }
             $march_id = 'e_march' . $this->counter . '_price';
             if (!isset(${$march_id})) {
                 return '';
             }
             if (${$march_id} == 0) {
                 return '';
             }
             $tva = new Acc_Tva($this->db, ${$id});
             if ($tva->load() == -1) {
                 return "";
             }
             $r = $tva->get_parameter('label');
             break;
             /* total VAT for one sold */
         /* total VAT for one sold */
         case 'TVA_AMOUNT':
         case 'VEN_TVA':
             extract($p_array);
             $qt = 'e_quant' . $this->counter;
             $price = 'e_march' . $this->counter . '_price';
             $tva = 'e_march' . $this->counter . '_tva_id';
             /* if we do not use vat this var. is not set */
             if (!isset(${$tva})) {
                 return '';
             }
             if (!isset(${'e_march' . $this->counter})) {
                 return "";
             }
             // check that something is sold
             if (${$price} == 0 || ${$qt} == 0 || strlen(trim($price)) == 0 || strlen(trim($qt)) == 0) {
                 return "";
             }
             $r = ${'e_march' . $this->counter . '_tva_amount'};
             break;
             /* TVA automatically computed */
         /* TVA automatically computed */
         case 'VEN_ART_TVA':
             extract($p_array);
             $qt = 'e_quant' . $this->counter;
             $price = 'e_march' . $this->counter . '_price';
             $tva = 'e_march' . $this->counter . '_tva_id';
             if (!isset(${'e_march' . $this->counter})) {
                 return "";
             }
             // check that something is sold
             if (${$price} == 0 || ${$qt} == 0 || strlen(trim($price)) == 0 || strlen(trim($qt)) == 0) {
                 return "";
             }
             $oTva = new Acc_Tva($this->db, ${$tva});
             if ($oTva->load() == -1) {
                 return "";
             }
             $r = round(${$price}, 2) * $oTva->get_parameter('rate');
             $r = round($r, 2);
             break;
         case 'VEN_ART_TVAC':
             extract($p_array);
             $qt = 'e_quant' . $this->counter;
             $price = 'e_march' . $this->counter . '_price';
             $tva = 'e_march' . $this->counter . '_tva_id';
             if (!isset(${'e_march' . $this->counter})) {
                 return "";
             }
             // check that something is sold
             if (${$price} == 0 || ${$qt} == 0 || strlen(trim($price)) == 0 || strlen(trim($qt)) == 0) {
                 return "";
             }
             if (!isset(${$tva})) {
                 return '';
             }
             $tva = new Acc_Tva($this->db, ${$tva});
             if ($tva->load() == -1) {
                 $r = round(${$price}, 2);
             } else {
                 $r = round(${$price} * $tva->get_parameter('rate') + ${$price}, 2);
             }
             break;
         case 'VEN_ART_QUANT':
             extract($p_array);
             $id = 'e_quant' . $this->counter;
             if (!isset(${$id})) {
                 return "";
             }
             // check that something is sold
             if (${'e_march' . $this->counter . '_price'} == 0 || ${'e_quant' . $this->counter} == 0 || strlen(trim(${'e_march' . $this->counter . '_price'})) == 0 || strlen(trim(${'e_quant' . $this->counter})) == 0) {
                 return "";
             }
             $r = ${$id};
             break;
         case 'VEN_HTVA':
             extract($p_array);
             $id = 'e_march' . $this->counter . '_price';
             $quant = 'e_quant' . $this->counter;
             if (!isset(${$id})) {
                 return "";
             }
             // check that something is sold
             if (${'e_march' . $this->counter . '_price'} == 0 || ${'e_quant' . $this->counter} == 0 || strlen(trim(${'e_march' . $this->counter . '_price'})) == 0 || strlen(trim(${'e_quant' . $this->counter})) == 0) {
                 return "";
             }
             bcscale(4);
             $r = bcmul(${$id}, ${$quant});
             $r = round($r, 2);
             break;
         case 'VEN_TVAC':
             extract($p_array);
             $id = 'e_march' . $this->counter . '_tva_amount';
             $price = 'e_march' . $this->counter . '_price';
             $quant = 'e_quant' . $this->counter;
             if (!isset(${'e_march' . $this->counter . '_price'}) || !isset(${'e_quant' . $this->counter})) {
                 return "";
             }
             // check that something is sold
             if (${'e_march' . $this->counter . '_price'} == 0 || ${'e_quant' . $this->counter} == 0) {
                 return "";
             }
             bcscale(4);
             // if TVA not exist
             if (!isset(${$id})) {
                 $r = bcmul(${$price}, ${$quant});
             } else {
                 $r = bcmul(${$price}, ${$quant});
                 $r = bcadd($r, ${$id});
             }
             $r = round($r, 2);
             return $r;
             break;
         case 'TOTAL_VEN_HTVA':
             extract($p_array);
             bcscale(4);
             $sum = 0.0;
             for ($i = 0; $i < $nb_item; $i++) {
                 $sell = 'e_march' . $i . '_price';
                 $qt = 'e_quant' . $i;
                 if (!isset(${$sell})) {
                     break;
                 }
                 if (strlen(trim(${$sell})) == 0 || strlen(trim(${$qt})) == 0 || ${$qt} == 0 || ${$sell} == 0) {
                     continue;
                 }
                 $tmp1 = bcmul(${$sell}, ${$qt});
                 $sum = bcadd($sum, $tmp1);
             }
             $r = round($sum, 2);
             break;
         case 'TOTAL_VEN_TVAC':
             extract($p_array);
             $sum = 0.0;
             bcscale(4);
             for ($i = 0; $i < $nb_item; $i++) {
                 $tva = 'e_march' . $i . '_tva_amount';
                 $tva_amount = 0;
                 /* if we do not use vat this var. is not set */
                 if (isset(${$tva})) {
                     $tva_amount = ${$tva};
                 }
                 $sell = ${'e_march' . $i . '_price'};
                 $qt = ${'e_quant' . $i};
                 $tot = bcmul($sell, $qt);
                 $tot = bcadd($tot, $tva_amount);
                 $sum = bcadd($sum, $tot);
             }
             $r = round($sum, 2);
             break;
         case 'TOTAL_TVA':
             extract($p_array);
             $sum = 0.0;
             for ($i = 0; $i < $nb_item; $i++) {
                 $tva = 'e_march' . $i . '_tva_amount';
                 if (!isset(${$tva})) {
                     $tva_amount = 0.0;
                 } else {
                     $tva_amount = ${$tva};
                 }
                 $sum += $tva_amount;
                 $sum = round($sum, 2);
             }
             $r = $sum;
             break;
         case 'BON_COMMANDE':
             if (isset($p_array['bon_comm'])) {
                 return $p_array['bon_comm'];
             } else {
                 return "";
             }
             break;
         case 'PJ':
             if (isset($p_array['e_pj'])) {
                 return $p_array['e_pj'];
             } else {
                 return "";
             }
         case 'OTHER_INFO':
             if (isset($p_array['other_info'])) {
                 return $p_array['other_info'];
             } else {
                 return "";
             }
             break;
         case 'COMMENT':
             if (isset($p_array['e_comm'])) {
                 return $p_array['e_comm'];
             }
             break;
         case 'ACOMPTE':
             if (isset($p_array['acompte'])) {
                 return $p_array['acompte'];
             }
             return "0";
             break;
         case 'STOCK_NAME':
             if (!isset($p_array['repo'])) {
                 return "";
             }
             $ret = $this->db->get_value('select r_name from public.stock_repository where r_id=$1', array($p_array['repo']));
             return $ret;
         case 'STOCK_ADRESS':
             if (!isset($p_array['repo'])) {
                 return "";
             }
             $ret = $this->db->get_value('select r_adress from public.stock_repository where r_id=$1', array($p_array['repo']));
             return $ret;
         case 'STOCK_COUNTRY':
             if (!isset($p_array['repo'])) {
                 return "";
             }
             $ret = $this->db->get_value('select r_country from public.stock_repository where r_id=$1', array($p_array['repo']));
             return $ret;
         case 'STOCK_CITY':
             if (!isset($p_array['repo'])) {
                 return "";
             }
             $ret = $this->db->get_value('select r_city from public.stock_repository where r_id=$1', array($p_array['repo']));
             return $ret;
         case 'STOCK_PHONE':
             if (!isset($p_array['repo'])) {
                 return "";
             }
             $ret = $this->db->get_value('select r_phone from public.stock_repository where r_id=$1', array($p_array['repo']));
             return $ret;
         case 'TITLE':
             $title = HtmlInput::default_value_request("ag_title", "");
             return $title;
     }
     /*
      * retrieve the value of ATTR for e_march
      */
     if (preg_match('/^ATTR/', $p_tag) == 1) {
         // Retrieve f_id
         if (isset($p_array['e_march' . $this->counter])) {
             $id = $p_array['e_march' . $this->counter];
             $r = $this->replace_special_tag($id, $p_tag);
         }
     }
     /*
      * retrieve the value of ATTR for e_march
      */
     if (preg_match('/^BENEFATTR/', $p_tag) == 1) {
         $qcode = isset($p_array['qcode_benef']) ? $p_array['qcode_benef'] : '';
         // Retrieve f_id
         $r = $this->replace_special_tag($qcode, $p_tag);
     }
     if (preg_match('/^CUSTATTR/', $p_tag) == 1) {
         if (isset($p_array['qcode_dest']) || isset($p_array['e_client'])) {
             $qcode = isset($p_array['qcode_dest']) ? $p_array['qcode_dest'] : $p_array['e_client'];
             $r = $this->replace_special_tag($qcode, $p_tag);
         }
     }
     return $r;
 }
 if (isset($_GET['poste_id']) && strlen(trim($_GET['poste_id'])) != 0) {
     if (isset($_GET['poste_fille'])) {
         $parent = $_GET['poste_id'];
         $a_poste = $cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like '{$parent}%' order by pcm_val::text");
         $go = 3;
     } elseif ($cn->count_sql('select * from tmp_pcmn where pcm_val=$1', array($_GET['poste_id'])) != 0) {
         $Poste = new Acc_Account_Ledger($cn, $_GET['poste_id']);
         $go = 1;
     }
 }
 if (strlen(trim($_GET['f_id'])) != 0) {
     require_once NOALYSS_INCLUDE . '/class_fiche.php';
     // thanks the qcode we found the poste account
     $fiche = new Fiche($cn);
     $qcode = $fiche->get_by_qcode($_GET['f_id']);
     $p = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
     if ($p != NOTFOUND) {
         $go = 2;
     }
 }
 // A account  is given
 if ($go == 1) {
     echo '<div class="content">';
     if (!isset($_REQUEST['oper_detail'])) {
         Acc_Account_Ledger::HtmlTableHeader();
         echo '<div class="content">';
         $Poste->HtmlTable(null, $_GET['ople']);
         echo '</div>';
         echo Acc_Account_Ledger::HtmlTableHeader();
     } else {
         //----------------------------------------------------------------------
 function display($p_array)
 {
     global $g_parameter, $g_user;
     require_once NOALYSS_INCLUDE . '/class_acc_ledger.php';
     $legder = new Acc_Ledger($this->db, $this->jrn_def_id);
     $legder->nb = $legder->get_min_row();
     if ($p_array != null) {
         extract($p_array);
     }
     $add_js = "";
     $ret = "";
     if ($g_user->check_action(FICADD) == 1) {
         /* Add button */
         $f_add_button = new IButton('add_card');
         $f_add_button->label = _('Créer une nouvelle fiche');
         $f_add_button->set_attribute('ipopup', 'ipop_newcard');
         $f_add_button->set_attribute('jrn', $legder->id);
         $f_add_button->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);";
         $f_add_button->input();
     }
     $nb_row = isset($nb_item) ? $nb_item : $legder->nb;
     $ret .= HtmlInput::hidden('nb_item', $nb_row);
     $ret .= HtmlInput::hidden('p_jrn', $this->jrn_def_id);
     $ret .= dossier::hidden();
     $ret .= dossier::hidden();
     $ret .= HtmlInput::hidden('jrn_type', $legder->get_type());
     $info = HtmlInput::infobulle(0);
     $info_poste = HtmlInput::infobulle(9);
     if ($g_user->check_action(FICADD) == 1) {
         $ret .= $f_add_button->input();
     }
     $ret .= '<table id="quick_item" style="width:100%">';
     $ret .= '<tr>' . '<th style="text-align:left">Quickcode' . $info . '</th>' . '<th style="text-align:left">' . _('Poste') . $info_poste . '</th>' . '<th style="text-align:left">' . _('Libellé') . '</th>' . '<th style="text-align:left">' . _('Montant') . '</th>' . '<th style="text-align:left">' . _('Débit') . '</th>' . '</tr>';
     for ($i = 0; $i < $nb_row; $i++) {
         // Quick Code
         $quick_code = new ICard('qc_' . $i);
         $quick_code->set_dblclick("fill_ipopcard(this);");
         $quick_code->set_attribute('ipopup', 'ipopcard');
         // name of the field to update with the name of the card
         $quick_code->set_attribute('label', "ld" . $i);
         $quick_code->set_attribute('jrn', $legder->id);
         // name of the field to update with the name of the card
         $quick_code->set_attribute('typecard', 'filter');
         // Add the callback function to filter the card on the jrn
         $quick_code->set_callback('filter_card');
         $quick_code->set_function('fill_data');
         $quick_code->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $quick_code->name);
         $quick_code->jrn = $legder->id;
         $quick_code->value = isset(${'qc_' . $i}) ? ${'qc_' . $i} : "";
         $label = '';
         if ($quick_code->value != '') {
             $Fiche = new Fiche($legder->db);
             $Fiche->get_by_qcode($quick_code->value);
             $label = $Fiche->strAttribut(ATTR_DEF_NAME);
         }
         // Account
         $poste = new IPoste();
         $poste->name = 'poste' . $i;
         $poste->set_attribute('jrn', $legder->id);
         $poste->set_attribute('ipopup', 'ipop_account');
         $poste->set_attribute('label', 'ld' . $i);
         $poste->set_attribute('account', 'poste' . $i);
         $poste->set_attribute('dossier', Dossier::id());
         $poste->value = isset(${'poste' . $i}) ? ${"poste" . $i} : '';
         $poste->dbl_click_history();
         if ($poste->value != '') {
             $Poste = new Acc_Account($legder->db);
             $Poste->set_parameter('value', $poste->value);
             $label = $Poste->get_lib();
         }
         // Description of the line
         $line_desc = new IText();
         $line_desc->name = 'ld' . $i;
         $line_desc->size = 30;
         $line_desc->value = isset(${"ld" . $i}) ? ${"ld" . $i} : $label;
         // Amount
         $amount = new INum();
         $amount->size = 10;
         $amount->name = 'amount' . $i;
         $amount->value = isset(${'amount' . $i}) ? ${"amount" . $i} : '';
         $amount->javascript = ' onChange="format_number(this);checkTotalDirect()"';
         // D/C
         $deb = new ICheckBox();
         $deb->name = 'ck' . $i;
         $deb->selected = isset(${'ck' . $i}) ? true : false;
         $deb->javascript = ' onChange="checkTotalDirect()"';
         $ret .= '<tr>';
         $ret .= '<td>' . $quick_code->input() . $quick_code->search() . '</td>';
         $ret .= '<td>' . $poste->input() . '<script> document.getElementById(\'poste' . $i . '\').onblur=function(){ if (trim(this.value) !=\'\') {document.getElementById(\'qc_' . $i . '\').value="";}}</script>' . '</td>';
         $ret .= '<td>' . $line_desc->input() . '</td>';
         $ret .= '<td>' . $amount->input() . '</td>';
         $ret .= '<td>' . $deb->input() . '</td>';
         $ret .= '</tr>';
         // If readonly == 1 then show CA
     }
     $ret .= '</table>';
     return $ret;
 }
 /**
  *@brief display a form for modifying or add a forecast
  *@return HTML code
  */
 public function form_item()
 {
     $forecast = new Forecast($this->cn, $this->f_id);
     $forecast->load();
     $str_name = $forecast->get_parameter('name');
     $str_start = $forecast->get_parameter('start_date');
     $str_end = $forecast->get_parameter('end_date');
     $r = "";
     $str_action = _("Elements");
     $cat = new Forecast_Cat($this->cn);
     $array = $cat->make_array($this->f_id);
     $periode = new Periode($this->cn);
     $aPeriode = $this->cn->make_array("select p_id,to_char(p_start,'MM.YYYY') as label from parm_periode\n                                  where p_start >= (select p_start from parm_periode where p_id={$str_start})\n                                   and p_end <= (select p_end from parm_periode where p_id={$str_end})\n\t\t\t\t   order by p_start");
     $aPeriode[] = array('value' => 0, 'label' => 'Mensuel');
     $value = $this->cn->get_array("select fi_id,fi_text,fi_account,fi_card,fc_id,fi_amount,fi_debit,fi_pid " . " from forecast_item " . " \twhere fc_id in (select fc_id from forecast_cat where f_id = \$1)", array($this->f_id));
     $max = count($value) < MAX_FORECAST_ITEM ? MAX_FORECAST_ITEM : count($value);
     $r .= HtmlInput::hidden('nbrow', $max);
     for ($i = 0; $i < $max; $i++) {
         if (isset($value[$i]['fi_id'])) {
             $r .= HtmlInput::hidden('fi_id' . $i, $value[$i]['fi_id']);
         }
         /* category*/
         $category = new ISelect();
         $category->name = 'an_cat' . $i;
         $category->value = $array;
         $category->selected = isset($value[$i]["fc_id"]) ? $value[$i]["fc_id"] : -1;
         $aCat[$i]['cat'] = $category->input();
         /* amount 	 */
         $amount = new INum('an_cat_amount' . $i);
         $amount->value = isset($value[$i]["fi_amount"]) ? $value[$i]["fi_amount"] : 0;
         $aCat[$i]['amount'] = $amount->input();
         /* Accounting*/
         $account = new IPoste('an_cat_acc' . $i);
         $account->set_attribute('ipopup', 'ipop_account');
         //            $account->set_attribute('label','an_label'.$i);
         $account->set_attribute('account', 'an_cat_acc' . $i);
         $account->set_attribute('bracket', 1);
         $account->set_attribute('no_overwrite', 1);
         $account->set_attribute('noquery', 1);
         $account->css_size = "85%";
         $account->value = isset($value[$i]["fi_account"]) ? $value[$i]["fi_account"] : "";
         $aCat[$i]['account'] = $account->input();
         /*Quick Code */
         $qc = new ICard('an_qc' . $i);
         // If double click call the javascript fill_ipopcard
         $qc->set_dblclick("fill_ipopcard(this);");
         // This attribute is mandatory, it is the name of the IPopup
         $qc->set_attribute('ipopup', 'ipopcard');
         // name of the field to update with the name of the card
         $qc->set_attribute('label', 'an_label' . $i);
         // Type of card : all
         $qc->set_attribute('typecard', 'all');
         $qc->set_attribute('jrn', 0);
         $qc->extra = 'all';
         // when value selected in the autcomplete
         $qc->set_function('fill_data');
         if (isset($value[$i]["fi_card"])) {
             $f = new Fiche($this->cn, $value[$i]["fi_card"]);
             $qc->value = $f->strAttribut(ATTR_DEF_QUICKCODE);
         }
         $aCat[$i]['qc'] = $qc->search() . $qc->input();
         /* Label */
         $label = new IText('an_label' . $i);
         $label->value = isset($value[$i]["fi_text"]) ? $value[$i]["fi_text"] : "";
         $aCat[$i]['name'] = $label->input();
         //Deb or Cred
         $deb = new ISelect('an_deb' . $i);
         $deb->selected = isset($value[$i]["fi_debit"]) ? $value[$i]["fi_debit"] : -1;
         $deb->value = array(array('value' => 'D', 'label' => _('Débit')), array('value' => 'C', 'label' => _('Crédit')));
         $aCat[$i]['deb'] = $deb->input();
         //Periode
         $isPeriode = new ISelect('month' . $i);
         $isPeriode->value = $aPeriode;
         $isPeriode->selected = isset($value[$i]["fi_pid"]) ? $value[$i]["fi_pid"] : 0;
         $aCat[$i]['per'] = $isPeriode->input();
     }
     $add_row = new IButton('add_row');
     $add_row->label = _('Ajouter une ligne');
     $add_row->javascript = 'for_add_row(\'fortable\')';
     $f_add_row = $add_row->input();
     ob_start();
     require_once NOALYSS_INCLUDE . '/template/forecast-detail.php';
     $r .= ob_get_contents();
     ob_end_clean();
     return $r;
 }
Beispiel #11
0
 function Display($p_readonly)
 {
     $this->GetAttribut();
     $attr = $this->attribut;
     /* show card type here */
     $type_card = $this->cn->get_value('select fd_label ' . ' from fiche_def join fiche using (fd_id) where f_id=$1', array($this->id));
     $ret = "";
     $ret .= h2(_("Catégorie") . " " . $type_card, 'style="display:inline"');
     $ret .= '<span style="font-weight:bolder;margin-right:5px;float:right">' . _('id fiche') . ':' . $this->id . "</span>";
     $ret .= "<table style=\"width:98%;margin:1%\">";
     if (empty($attr)) {
         return 'FNT';
     }
     /* for each attribute */
     foreach ($attr as $r) {
         $msg = "";
         $bulle = "";
         if ($p_readonly) {
             $w = new IText();
             $w->table = 1;
             $w->readOnly = true;
             $w->css_size = "100%";
         }
         if ($p_readonly == false) {
             if ($r->ad_id == ATTR_DEF_ACCOUNT) {
                 $w = new IPoste("av_text" . $r->ad_id);
                 $w->set_attribute('ipopup', 'ipop_account');
                 $w->set_attribute('account', "av_text" . $r->ad_id);
                 $w->dbl_click_history();
                 //  account created automatically
                 $w->table = 0;
                 $w->value = $r->av_text;
                 //  account created automatically
                 $sql = "select account_auto({$this->fiche_def})";
                 $ret_sql = $this->cn->exec_sql($sql);
                 $a = Database::fetch_array($ret_sql, 0);
                 $bulle = HtmlInput::infobulle(10);
                 if ($a['account_auto'] == 't') {
                     $bulle .= HtmlInput::warnbulle(11);
                 }
             } elseif ($r->ad_id == ATTR_DEF_TVA) {
                 $w = new ITva_Popup('popup_tva');
                 $w->table = 1;
                 $w->value = $r->av_text;
             } else {
                 switch ($r->ad_type) {
                     case 'text':
                         $w = new IText('av_text' . $r->ad_id);
                         $w->css_size = "100%";
                         $w->value = $r->av_text;
                         break;
                     case 'numeric':
                         $w = new INum('av_text' . $r->ad_id);
                         $w->size = $r->ad_size;
                         $w->prec = $r->ad_extra == "" ? 2 : $r->ad_extra;
                         $w->value = $r->av_text;
                         break;
                     case 'date':
                         $w = new IDate('av_text' . $r->ad_id);
                         $w->value = $r->av_text;
                         break;
                     case 'zone':
                         $w = new ITextArea('av_text' . $r->ad_id);
                         $w->style = ' class="itextarea" style="margin:0px;width:100%"';
                         $w->value = $r->av_text;
                         break;
                     case 'poste':
                         $w = new IPoste("av_text" . $r->ad_id);
                         $w->set_attribute('ipopup', 'ipop_account');
                         $w->set_attribute('account', "av_text" . $r->ad_id);
                         $w->dbl_click_history();
                         $w->width = $r->ad_size;
                         $w->table = 0;
                         $bulle = HtmlInput::infobulle(14);
                         $w->value = $r->av_text;
                         break;
                     case 'card':
                         $uniq = rand(0, 1000);
                         $w = new ICard("av_text" . $r->ad_id);
                         $w->id = "card_" . $this->id . $uniq;
                         // filter on ad_extra
                         $filter = $r->ad_extra;
                         $w->width = $r->ad_size;
                         $w->extra = $filter;
                         $w->extra2 = 0;
                         $label = new ISpan();
                         $label->name = "av_text" . $uniq . $r->ad_id . "_label";
                         $fiche = new Fiche($this->cn);
                         $fiche->get_by_qcode($r->av_text);
                         if ($fiche->id == 0) {
                             $label->value = trim($r->av_text) == '' ? "" : " " . _("Fiche non trouvée") . " ";
                             $r->av_text = "";
                         } else {
                             $label->value = $fiche->strAttribut(ATTR_DEF_NAME) . " " . $fiche->strAttribut(ATTR_DEF_FIRST_NAME, 0);
                         }
                         $w->set_attribute('ipopup', 'ipopcard');
                         $w->set_attribute('typecard', $filter);
                         $w->set_attribute('inp', "av_text" . $r->ad_id);
                         $w->set_attribute('label', $label->name);
                         $w->autocomplete = 0;
                         $w->dblclick = "fill_ipopcard(this);";
                         $msg = $w->search();
                         $msg .= $label->input();
                         $w->value = $r->av_text;
                         break;
                     case 'select':
                         $w = new ISelect();
                         $w->value = $this->cn->make_array($r->ad_extra);
                         $w->selected = $r->av_text;
                         $w->style = ' style="width:100%" ';
                         break;
                     default:
                         var_dump($r);
                         throw new Exception("Type invalide");
                 }
                 $w->table = 0;
             }
         } else {
             switch ($r->ad_type) {
                 case 'select':
                     $x = new ISelect();
                     $x->value = $this->cn->make_array($r->ad_extra);
                     $x->selected = $r->av_text;
                     $value = $x->display();
                     $w->value = $value;
                     break;
                 default:
                     $w->value = $r->av_text;
             }
         }
         $w->name = "av_text" . $r->ad_id;
         $w->readOnly = $p_readonly;
         if ($r->ad_id == 21 || $r->ad_id == 22 || $r->ad_id == 20 || $r->ad_id == 31) {
             $bulle = HtmlInput::infobulle(21);
         }
         $ret .= "<TR>" . td(_($r->ad_text) . $bulle) . td($w->input() . " " . $msg) . " </TR>";
     }
     $ret .= "</table>";
     return $ret;
 }
Beispiel #12
0
 /**
  * myList($p_base, $p_filter = "", $p_search = "") 
  * Show list of action by default if sorted on date
  * @param $p_base base url with ac...
  * @param $p_filter filters on the document_type
  * @param $p_search must a valid sql command ( ex 'and  ag_title like upper('%hjkh%'))
  * @return string containing html code
  */
 function myList($p_base, $p_filter = "", $p_search = "")
 {
     // for the sort
     $url = HtmlInput::get_to_string(array("closed_action", "remind_date_end", "remind_date", "sag_ref", "only_internal", "state", "qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate", "searchtag")) . '&' . $p_base;
     $table = new Sort_Table();
     $table->add('Date Doc.', $url, 'order by ag_timestamp asc', 'order by ag_timestamp desc', 'da', 'dd');
     $table->add('Date Comm.', $url, 'order by last_comment', 'order by last_comment desc', 'dca', 'dcd');
     $table->add('Date Limite', $url, 'order by ag_remind_date asc', 'order by ag_remind_date  desc', 'ra', 'rd');
     $table->add('Tag', $url, 'order by tags asc', 'order by tags desc', 'taa', 'tad');
     $table->add('Réf.', $url, 'order by ag_ref asc', 'order by ag_ref desc', 'ra', 'rd');
     $table->add('Groupe', $url, "order by coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe')", "order by coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') desc", 'dea', 'ded');
     $table->add('Dest/Exp', $url, 'order by name asc', 'order by name desc', 'ea', 'ed');
     $table->add('Titre', $url, 'order by ag_title asc', 'order by ag_title desc', 'ta', 'td');
     $ord = !isset($_GET['ord']) ? "dcd" : $_GET['ord'];
     $sort = $table->get_sql_order($ord);
     if (strlen(trim($p_filter)) != 0) {
         $p_filter_doc = " dt_id in ( {$p_filter} )";
     } else {
         $p_filter_doc = " 1=1 ";
     }
     $sql = "\n             select ag_id,to_char(ag_timestamp,'DD.MM.YYYY') as my_date,\n                to_char(ag_remind_date,'DD.MM.YYYY') as my_remind,\n                to_char(coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp),'DD.MM.YY') as str_last_comment,\n                coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp) as last_comment,\n                f_id_dest,\n                s_value,\n                ag_title,dt_value,ag_ref, ag_priority,ag_state,\n                coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest,\n                (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=1) as name,\n                array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags\n            from action_gestion as ag\n                join document_type on (ag_type=dt_id)\n                join document_state on (ag_state=s_id)\n             where {$p_filter_doc} {$p_search} {$sort}";
     $max_line = $this->db->count_sql($sql);
     $step = $_SESSION['g_pagesize'];
     $page = isset($_GET['offset']) ? $_GET['page'] : 1;
     $offset = isset($_GET['offset']) ? Database::escape_string($_GET['offset']) : 0;
     if ($step != -1) {
         $limit = " LIMIT {$step} OFFSET {$offset} ";
     } else {
         $limit = '';
     }
     $bar = navigation_bar($offset, $max_line, $step, $page);
     $Res = $this->db->exec_sql($sql . $limit);
     $a_row = Database::fetch_all($Res);
     $r = "";
     $r .= '<p>' . $bar . '</p>';
     $r .= '<table class="document">';
     $r .= "<tr>";
     $r .= '<th name="ag_id_td" style="display:none" >' . ICheckBox::toggle_checkbox('ag', 'list_ag_frm') . '</th>';
     $r .= '<th>' . $table->get_header(0) . '</th>';
     $r .= '<th>' . $table->get_header(1) . '</th>';
     $r .= '<th>' . $table->get_header(2) . '</th>';
     $r .= '<th>' . $table->get_header(3) . '</th>';
     $r .= '<th>' . $table->get_header(4) . '</th>';
     $r .= '<th>' . $table->get_header(5) . '</th>';
     $r .= '<th>' . $table->get_header(6) . '</th>';
     $r .= '<th>' . $table->get_header(7) . '</th>';
     $r .= th('Priorité');
     $r .= "</tr>";
     // if there are no records return a message
     if (sizeof($a_row) == 0 or $a_row == false) {
         $r = '<div style="clear:both">';
         $r .= '<hr>Aucun enregistrement trouvé';
         $r .= "</div>";
         return $r;
     }
     $today = date('d.m.Y');
     $i = 0;
     $checkbox = new ICheckBox("mag_id[]");
     //show the sub_action
     foreach ($a_row as $row) {
         $href = '<A class="document" HREF="do.php?' . $p_base . HtmlInput::get_to_string(array("closed_action", "remind_date_end", "remind_date", "sag_ref", "only_internal", "state", "gDossier", "qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate", "searchtag", "ac"), "&") . '&sa=detail&ag_id=' . $row['ag_id'] . '">';
         $i++;
         $tr = $i % 2 == 0 ? 'even' : 'odd';
         if ($row['ag_priority'] < 2) {
             $tr = 'priority1';
         }
         $st = '';
         if ($row['my_date'] == $today) {
             $st = ' style="font-weight:bold; border:2px solid orange;"';
         }
         $date_remind = format_date($row['my_remind'], 'DD.MM.YYYY', 'YYYYMMDD');
         $date_today = date('Ymd');
         if ($date_remind != "" && $date_remind == $date_today && $row['ag_state'] != 1 && $row['ag_state'] != 3) {
             $st = ' style="font-weight:bold;background:orange"';
         }
         if ($date_remind != "" && $date_remind < $date_today && $row['ag_state'] != 1 && $row['ag_state'] != 3) {
             $st = ' style="font-weight:bold;background:#FF0000;color:white;"';
         }
         $r .= "<tr class=\"{$tr}\" {$st}>";
         $checkbox->value = $row['ag_id'];
         $r .= '<td name="ag_id_td" style="display:none">' . $checkbox->input() . '</td>';
         $r .= "<td>" . $href . smaller_date($row['my_date']) . '</a>' . "</td>";
         $r .= "<td>" . $href . $row['str_last_comment'] . '</a>' . "</td>";
         $r .= "<td>" . $href . smaller_date($row['my_remind']) . '</a>' . "</td>";
         $r .= "<td>" . $href . h($row['tags']) . '</a>' . "</td>";
         $r .= "<td>" . $href . $row['ag_ref'] . '</a>' . "</td>";
         $r .= "<td>" . $href . h($row['dest']) . '</a>' . "</td>";
         // Expediteur
         $fexp = new Fiche($this->db);
         $fexp->id = $row['f_id_dest'];
         $qcode_dest = $fexp->strAttribut(ATTR_DEF_QUICKCODE);
         $qexp = $qcode_dest == NOTFOUND ? "Interne" : $qcode_dest;
         $jsexp = sprintf("javascript:showfiche('%s')", $qexp);
         if ($qexp != 'Interne') {
             $r .= "<td>{$href}" . $qexp . " : " . $fexp->getName() . '</a></td>';
         } else {
             $r .= "<td>{$href} Interne </a></td>";
         }
         $ref = "";
         $r .= '<td>' . $href . h($row['ag_title']) . "</A></td>";
         /*
          * State
          */
         switch ($row['ag_priority']) {
             case 1:
                 $priority = 'Haute';
                 break;
             case 2:
                 $priority = "Moyenne";
                 break;
             case 3:
                 $priority = "Important";
                 break;
         }
         $r .= td($priority);
         $r .= "<td>" . $ref . "</td>";
         $r .= "</tr>";
     }
     $r .= "</table>";
     $r .= '<p>' . $bar . '</p>';
     return $r;
 }
 function input($p_array = null, $p_readonly = 0)
 {
     global $g_parameter, $g_user;
     if ($p_array != null) {
         extract($p_array);
     }
     $flag_tva = $g_parameter->MY_TVA_USE;
     /* Add button */
     $f_add_button = new IButton('add_card');
     $f_add_button->tabindex = -1;
     $f_add_button->label = _('Créer une nouvelle fiche');
     $f_add_button->set_attribute('ipopup', 'ipop_newcard');
     $f_add_button->set_attribute('jrn', $this->id);
     $f_add_button->javascript = "this.jrn=\$('p_jrn').value; select_card_type(this);";
     $f_add_button2 = new IButton('add_card2');
     $f_add_button2->tabindex = -1;
     $f_add_button2->label = _('Créer une nouvelle fiche');
     $f_add_button2->set_attribute('ipopup', 'ipop_newcard');
     $f_add_button2->set_attribute('filter', $this->get_all_fiche_def());
     //    $f_add_button2->set_attribute('jrn',$this->id);
     $f_add_button2->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);";
     $str_add_button = "";
     $str_add_button2 = "";
     if ($g_user->check_action(FICADD) == 1) {
         $str_add_button = $f_add_button->input();
         $str_add_button2 = $f_add_button2->input();
     }
     // The first day of the periode
     $oPeriode = new Periode($this->db);
     list($l_date_start, $l_date_end) = $oPeriode->get_date_limit($g_user->get_periode());
     if ($g_parameter->MY_DATE_SUGGEST == 'Y') {
         $op_date = !isset($e_date) ? $l_date_start : $e_date;
     } else {
         $op_date = !isset($e_date) ? '' : $e_date;
     }
     $e_ech = isset($e_ech) ? $e_ech : "";
     $e_comm = isset($e_comm) ? $e_comm : "";
     $r = '';
     $r .= dossier::hidden();
     $f_legend = _('Client');
     $Echeance = new IDate();
     $Echeance->setReadOnly(false);
     $Echeance->tabindex = 2;
     $label = HtmlInput::infobulle(4);
     $f_echeance = $Echeance->input('e_ech', $e_ech, _('Echéance') . $label);
     $Date = new IDate();
     $Date->setReadOnly(false);
     $f_date = $Date->input("e_date", $op_date);
     $f_periode = '';
     // Periode
     //--
     if ($this->check_periode() == true) {
         $l_user_per = $g_user->get_periode();
         $def = isset($periode) ? $periode : $l_user_per;
         $period = new IPeriod("period");
         $period->user = $g_user;
         $period->cn = $this->db;
         $period->value = $def;
         $period->type = OPEN;
         try {
             $l_form_per = $period->input();
         } catch (Exception $e) {
             if ($e->getCode() == 1) {
                 throw new Exception(_("Aucune période ouverte"));
             }
         }
         $label = HtmlInput::infobulle(3);
         $f_periode = '<td>' . _("Période comptable") . "</td> <td> {$label} " . $l_form_per . '</td>';
     }
     /* if we suggest the next pj, then we need a javascript */
     $add_js = "";
     if ($g_parameter->MY_PJ_SUGGEST == 'Y') {
         $add_js = "update_pj();";
     }
     if ($g_parameter->MY_DATE_SUGGEST == 'Y') {
         $add_js .= 'get_last_date();';
     }
     $add_js .= 'update_name();';
     $add_js .= 'update_pay_method();';
     $add_js .= 'update_row("sold_item");';
     $wLedger = $this->select_ledger('VEN', 2);
     if ($wLedger == null) {
         throw new Exception(_('Pas de journal disponible'));
     }
     $wLedger->table = 1;
     $wLedger->javascript = "onChange='update_predef(\"ven\",\"f\",\"" . $_REQUEST['ac'] . "\");{$add_js}'";
     $wLedger->label = " Journal " . HtmlInput::infobulle(2);
     $f_jrn = $wLedger->input();
     $Commentaire = new IText();
     $Commentaire->table = 0;
     $Commentaire->setReadOnly(false);
     $Commentaire->size = 60;
     $Commentaire->tabindex = 3;
     $label = HtmlInput::infobulle(1);
     $f_desc = $Commentaire->input("e_comm", h($e_comm));
     // PJ
     //--
     /* suggest PJ ? */
     $default_pj = '';
     if ($g_parameter->MY_PJ_SUGGEST == 'Y') {
         $default_pj = $this->guess_pj();
     }
     $pj = new IText();
     $pj->table = 0;
     $pj->name = "e_pj";
     $pj->size = 10;
     $pj->value = isset($e_pj) ? $e_pj : $default_pj;
     $f_pj = $pj->input() . HtmlInput::hidden('e_pj_suggest', $default_pj);
     // Display the customer
     //--
     $fiche = 'deb';
     // Save old value and set a new one
     //--
     $e_client = isset($e_client) ? $e_client : "";
     $e_client_label = "&nbsp;";
     //str_pad("",100,".");
     // retrieve e_client_label
     //--
     if (strlen(trim($e_client)) != 0) {
         $fClient = new Fiche($this->db);
         $fClient->get_by_qcode($e_client);
         $e_client_label = $fClient->strAttribut(ATTR_DEF_NAME) . ' ' . ' Adresse : ' . $fClient->strAttribut(ATTR_DEF_ADRESS) . ' ' . $fClient->strAttribut(ATTR_DEF_CP) . ' ' . $fClient->strAttribut(ATTR_DEF_CITY) . ' ';
     }
     $W1 = new ICard();
     $W1->label = "Client " . HtmlInput::infobulle(0);
     $W1->name = "e_client";
     $W1->tabindex = 3;
     $W1->value = $e_client;
     $W1->table = 0;
     $W1->set_dblclick("fill_ipopcard(this);");
     $W1->set_attribute('ipopup', 'ipopcard');
     // name of the field to update with the name of the card
     $W1->set_attribute('label', 'e_client_label');
     // name of the field to update with the name of the card
     $W1->set_attribute('typecard', 'deb');
     // Add the callback function to filter the card on the jrn
     $W1->set_callback('filter_card');
     $W1->set_function('fill_data');
     $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
     $f_client_qcode = $W1->input();
     $client_label = new ISpan();
     $client_label->table = 0;
     $f_client = $client_label->input("e_client_label", $e_client_label);
     $f_client_bt = $W1->search();
     // Record the current number of article
     $Hid = new IHidden();
     $p_article = isset($nb_item) ? $nb_item : $this->get_min_row();
     $r .= $Hid->input("nb_item", $p_article);
     $max = $p_article < $this->get_min_row() ? $this->get_min_row() : $p_article;
     $f_legend_detail = _("Détail articles vendus");
     // For each article
     //--
     for ($i = 0; $i < $max; $i++) {
         // Code id, price & vat code
         //--
         $march = isset(${"e_march{$i}"}) ? ${"e_march{$i}"} : "";
         $march_price = isset(${"e_march" . $i . "_price"}) ? ${"e_march" . $i . "_price"} : "";
         if ($flag_tva == 'Y') {
             $march_tva_id = isset(${"e_march{$i}" . "_tva_id"}) ? ${"e_march{$i}" . "_tva_id"} : "";
             $march_tva_amount = isset(${"e_march{$i}" . "_tva_amount"}) ? ${"e_march{$i}" . "_tva_amount"} : "";
         }
         $march_label = isset(${"e_march" . $i . "_label"}) ? ${"e_march" . $i . "_label"} : "";
         // retrieve the tva label and name
         //--
         if (strlen(trim($march)) != 0 && strlen(trim($march_label)) == 0) {
             $fMarch = new Fiche($this->db);
             $fMarch->get_by_qcode($march);
             $march_label = $fMarch->strAttribut(ATTR_DEF_NAME);
             if ($flag_tva == 'Y') {
                 if (!isset(${"e_march{$i}" . "_tva_id"})) {
                     $march_tva_id = $fMarch->strAttribut(ATTR_DEF_TVA);
                 }
             }
         }
         // Show input
         //--
         $W1 = new ICard();
         $W1->label = "";
         $W1->name = "e_march" . $i;
         $W1->value = $march;
         $W1->table = 1;
         $W1->set_attribute('typecard', 'cred');
         $W1->set_dblclick("fill_ipopcard(this);");
         $W1->set_attribute('ipopup', 'ipopcard');
         // name of the field to update with the name of the card
         $W1->set_attribute('label', 'e_march' . $i . '_label');
         // name of the field with the price
         $W1->set_attribute('price', 'e_march' . $i . '_price');
         // name of the field with the TVA_ID
         $W1->set_attribute('tvaid', 'e_march' . $i . '_tva_id');
         // Add the callback function to filter the card on the jrn
         $W1->set_callback('filter_card');
         $W1->set_function('fill_data');
         $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
         $W1->readonly = false;
         $array[$i]['quick_code'] = $W1->input();
         $array[$i]['bt'] = $W1->search();
         // For computing we need some hidden field for holding the value
         $array[$i]['hidden'] = '';
         if ($flag_tva == 'Y') {
             $array[$i]['hidden'] .= HtmlInput::hidden('tva_march' . $i, 0);
         }
         $htva = new INum('htva_march' . $i);
         $htva->readOnly = 1;
         $htva->value = 0;
         $array[$i]['htva'] = $htva->input();
         if ($g_parameter->MY_TVA_USE == 'Y') {
             $tvac = new INum('tvac_march' . $i);
         } else {
             $tvac = new IHidden('tvac_march' . $i);
         }
         $tvac->readOnly = 1;
         $tvac->value = 0;
         $array[$i]['tvac'] = $tvac->input();
         if ($g_parameter->MY_UPDLAB == 'Y') {
             $Span = new IText("e_march" . $i . "_label");
             $Span->css_size = "100%";
         } else {
             $Span = new ISpan("e_march" . $i . "_label");
         }
         $Span->value = $march_label;
         $Span->setReadOnly(false);
         // card's name, price
         //--
         $array[$i]['denom'] = $Span->input("e_march" . $i . "_label", $march_label);
         // price
         $Price = new INum();
         $Price->setReadOnly(false);
         $Price->size = 9;
         $Price->javascript = "onBlur='format_number(this);clean_tva({$i});compute_ledger({$i})'";
         $array[$i]['pu'] = $Price->input("e_march" . $i . "_price", $march_price);
         $array[$i]['tva'] = '';
         $array[$i]['amount_tva'] = '';
         // if tva is not needed then no tva field
         if ($flag_tva == 'Y') {
             // vat label
             //--
             $Tva = new ITva_Popup($this->db);
             $Tva->in_table = true;
             $Tva->set_attribute('compute', $i);
             $Tva->js = 'onblur="format_number(this);clean_tva(' . $i . ');compute_ledger(' . $i . ')"';
             $Tva->value = $march_tva_id;
             $array[$i]['tva'] = $Tva->input("e_march{$i}" . "_tva_id");
             // vat amount
             //--
             $wTva_amount = new INum();
             $wTva_amount->readOnly = false;
             $wTva_amount->size = 6;
             $wTva_amount->javascript = "onBlur='format_number(this);compute_ledger({$i})'";
             $array[$i]['amount_tva'] = $wTva_amount->input("e_march" . $i . "_tva_amount", $march_tva_amount);
         }
         // quantity
         //--
         $quant = isset(${"e_quant{$i}"}) ? ${"e_quant{$i}"} : "1";
         $Quantity = new INum();
         $Quantity->setReadOnly(false);
         $Quantity->size = 8;
         $Quantity->javascript = "onChange='format_number(this);clean_tva({$i});compute_ledger({$i})'";
         $array[$i]['quantity'] = $Quantity->input("e_quant" . $i, $quant);
     }
     // foreach article
     $f_type = _('Client');
     ob_start();
     require_once NOALYSS_INCLUDE . '/template/form_ledger_detail.php';
     $r .= ob_get_contents();
     ob_end_clean();
     // Set correctly the REQUEST param for jrn_type
     $r .= HtmlInput::hidden('jrn_type', 'VEN');
     $r .= HtmlInput::button('add_item', _('Ajout article'), ' onClick="ledger_add_row()"');
     $r .= create_script("\$('" . $Date->id . "').focus()");
     return $r;
 }
    $a_anc = $anc->get_list(' order by pa_id ');
    $x = count($a_anc);
    /* set the width of the col */
    $str_anc .= '<th colspan="' . $x . '" style="width:auto;text-align:center">' . _('Compt. Analytique') . '</th>';
    /* add hidden variables pa[] to hold the value of pa_id */
    $str_anc .= Anc_Plan::hidden($a_anc);
}
bcscale(2);
for ($e = 0; $e < count($detail->det->array); $e++) {
    $row = '';
    $q = $detail->det->array;
    $fiche = new Fiche($cn);
    $fiche->get_by_qcode($q[$e]['j_qcode']);
    /* Analytic accountancy */
    if ($owner->MY_ANALYTIC != "nu") {
        $poste = $fiche->strAttribut(ATTR_DEF_ACCOUNT);
        if (preg_match('/^(6|7)/', $q[$e]['j_poste'])) {
            $qcode = $fiche->strAttribut(ATTR_DEF_QUICKCODE);
            $anc_op = new Anc_Operation($cn);
            $anc_op->j_id = $q[$e]['j_id'];
            $anc_op->in_div = $div;
            $str_anc .= '<tr>';
            $str_anc .= td($poste);
            $str_anc .= td($qcode);
            $str_anc .= td(nbm($q[$e]['j_montant']));
            $str_anc .= '<td>';
            $str_anc .= HtmlInput::hidden('op[]', $anc_op->j_id);
            $montant = $q[$e]['j_debit'] == "t" ? $q[$e]['j_montant'] : bcmul($q[$e]['j_montant'], -1);
            $str_anc .= $anc_op->display_table(1, $montant, $div);
            $str_anc .= '</td>';
            $str_anc .= '</tr>';
Beispiel #15
0
                $old = _("Autre exercice") . " " . $is->input();
            } else {
                $old = '<form method="get" action="popup.php">';
                $is = $exercice->select('ex', $default, 'onchange = "submit(this)"');
                $old .= _("Autre exercice") . " " . $is->input();
                $old .= HtmlInput::hidden('div', 'popup');
                $old .= HtmlInput::hidden('act', $_GET['act']);
                $old .= HtmlInput::hidden('f_id', $_GET['f_id']);
                $old .= HtmlInput::hidden('ajax', $_GET['ajax']);
                $old .= dossier::hidden();
                $old .= '</form>';
            }
        }
        ob_start();
        require_once NOALYSS_INCLUDE . '/template/history_top.php';
        $detail_card = HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE), $fiche->getName());
        echo h2($fiche->getName() . '[' . $fiche->strAttribut(ATTR_DEF_QUICKCODE) . ']', ' class="title" ');
        echo '<p style="text-align:center;">' . $detail_card . '</p>';
        if ($fiche->HtmlTable($array, 0, $from_div) == -1) {
            echo h2(_("Aucune opération pour l'exercice courant"), 'class="error"');
        }
        echo $old;
        $html = ob_get_contents();
        ob_end_clean();
    }
}
///////////////////////////////////////////////////////////////////////////
// for an account
///////////////////////////////////////////////////////////////////////////
if (isset($_REQUEST['pcm_val'])) {
    $poste = new Acc_Account_Ledger($cn, $_REQUEST['pcm_val']);
     $fiche = new Fiche($cn);
     $fiche->get_by_qcode($q[$e]['j_qcode']);
     $view_history = sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:view_history_card(\'%s\',\'%s\')" >%s</A>', $fiche->id, $gDossier, $q[$e]['j_qcode']);
 } else {
     $view_history = '';
 }
 $row .= td($view_history);
 $l_lib = $q[$e]['j_text'];
 if ($l_lib != '') {
     $l_lib = $q[$e]['j_text'];
 } else {
     if ($q[$e]['j_qcode'] != '') {
         // nom de la fiche
         $ff = new Fiche($cn);
         $ff->get_by_qcode($q[$e]['j_qcode']);
         $l_lib = $ff->strAttribut(ATTR_DEF_NAME);
     } else {
         // libellé du compte
         $name = $cn->get_value('select pcm_lib from tmp_pcmn where pcm_val=$1', array($q[$e]['j_poste']));
         $l_lib = $name;
     }
 }
 $l_lib = strip_tags($l_lib);
 if ($owner->MY_UPDLAB == 'Y') {
     $hidden = HtmlInput::hidden("j_id[]", $q[$e]['j_id']);
     $input = new IText("e_march" . $q[$e]['j_id'] . "_label", $l_lib);
     $input->css_size = "100%";
 } else {
     $input = new ISpan("e_march" . $q[$e]['j_id'] . "_label");
     $input->value = $l_lib;
     $hidden = HtmlInput::hidden("j_id[]", $q[$e]['j_id']);
 function display($p_array)
 {
     require_once NOALYSS_INCLUDE . '/class_acc_ledger_purchase.php';
     global $g_parameter, $g_user;
     extract($p_array);
     $ledger = new Acc_Ledger_Purchase($this->db, $this->jrn_def_id);
     if ($p_array != null) {
         extract($p_array);
     }
     $flag_tva = $g_parameter->MY_TVA_USE;
     /* Add button */
     $f_add_button = new IButton('add_card');
     $f_add_button->label = _('Créer une nouvelle fiche');
     $f_add_button->tabindex = -1;
     $f_add_button->set_attribute('ipopup', 'ipop_newcard');
     $f_add_button->set_attribute('jrn', $this->jrn_def_id);
     $f_add_button->javascript = " this.jrn=\$('p_jrn').value;select_card_type(this);";
     $f_add_button2 = new IButton('add_card2');
     $f_add_button2->tabindex = -1;
     $f_add_button2->label = _('Créer une nouvelle fiche');
     $f_add_button2->set_attribute('ipopup', 'ipop_newcard');
     $f_add_button2->set_attribute('filter', $ledger->get_all_fiche_def());
     //    $f_add_button2->set_attribute('jrn',$ledger->id);
     $f_add_button2->javascript = "  this.jrn=\$('p_jrn').value;select_card_type(this);";
     $str_add_button = "";
     $str_add_button2 = "";
     if ($g_user->check_action(FICADD) == 1) {
         $str_add_button = $f_add_button->input();
         $str_add_button2 = $f_add_button2->input();
     }
     $r = "";
     $r .= dossier::hidden();
     $f_legend = _("En-tête facture fournisseur");
     $f_legend_detail = _("Détail articles acheté");
     // Ledger (p_jrn)
     //--
     /* if we suggest the next pj, then we need a javascript */
     $add_js = "";
     // Display the customer
     //--
     $fiche = 'cred';
     // Save old value and set a new one
     //--
     $e_client = isset($e_client) ? $e_client : "";
     $e_client_label = "&nbsp;";
     //str_pad("",100,".");
     // retrieve e_client_label
     //--
     if (strlen(trim($e_client)) != 0) {
         $fClient = new Fiche($ledger->db);
         $fClient->get_by_qcode($e_client);
         $e_client_label = $fClient->strAttribut(ATTR_DEF_NAME) . ' ' . ' Adresse : ' . $fClient->strAttribut(ATTR_DEF_ADRESS) . ' ' . $fClient->strAttribut(ATTR_DEF_CP) . ' ' . $fClient->strAttribut(ATTR_DEF_CITY) . ' ';
     }
     $W1 = new ICard();
     $W1->label = _("Fournisseur ") . HtmlInput::infobulle(0);
     $W1->name = "e_client";
     $W1->tabindex = 3;
     $W1->value = $e_client;
     $W1->table = 0;
     $W1->set_dblclick("fill_ipopcard(this);");
     $W1->set_attribute('ipopup', 'ipopcard');
     // name of the field to update with the name of the card
     $W1->set_attribute('label', 'e_client_label');
     // name of the field to update with the name of the card
     $W1->set_attribute('typecard', 'cred');
     // Add the callback function to filter the card on the jrn
     $W1->set_callback('filter_card');
     $W1->set_function('fill_data');
     $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
     $f_client_qcode = $W1->input();
     $client_label = new ISpan();
     $client_label->table = 0;
     $f_client = $client_label->input("e_client_label", $e_client_label);
     $f_client_bt = $W1->search();
     // Record the current number of article
     $min = $ledger->get_min_row();
     $p_article = isset($nb_item) ? $nb_item : $min;
     $max = $p_article < $min ? $min : $p_article;
     $e_comment = isset($e_comment) ? $e_comment : "";
     $Hid = new IHidden();
     $r .= $Hid->input("nb_item", $p_article);
     // For each article
     //--
     for ($i = 0; $i < $max; $i++) {
         // Code id, price & vat code
         //--
         $march = isset(${"e_march{$i}"}) ? ${"e_march{$i}"} : "";
         $march_price = isset(${"e_march" . $i . "_price"}) ? ${"e_march" . $i . "_price"} : "";
         /* use vat */
         if ($g_parameter->MY_TVA_USE == 'Y') {
             $march_tva_id = isset(${"e_march{$i}" . "_tva_id"}) ? ${"e_march{$i}" . "_tva_id"} : "";
             $march_tva_amount = isset(${"e_march{$i}" . "_tva_amount"}) ? ${"e_march{$i}" . "_tva_amount"} : "";
         }
         $march_label = isset(${"e_march" . $i . "_label"}) ? ${"e_march" . $i . "_label"} : "";
         // retrieve the tva label and name
         //--
         if (strlen(trim($march)) != 0 && strlen(trim($march_label)) == 0) {
             $fMarch = new Fiche($ledger->db);
             $fMarch->get_by_qcode($march);
             $march_label = $fMarch->strAttribut(ATTR_DEF_NAME);
             /* vat use */
             if (!isset($march_tva_id) && $g_parameter->MY_TVA_USE == 'Y') {
                 $march_tva_id = $fMarch->strAttribut(ATTR_DEF_TVA);
             }
         }
         // Show input
         //--
         $W1 = new ICard();
         $W1->label = "";
         $W1->name = "e_march" . $i;
         $W1->value = $march;
         $W1->table = 1;
         $W1->set_dblclick("fill_ipopcard(this);");
         $W1->set_attribute('ipopup', 'ipopcard');
         $W1->set_attribute('typecard', 'deb');
         // name of the field to update with the name of the card
         $W1->set_attribute('label', 'e_march' . $i . '_label');
         // name of the field with the price
         $W1->set_attribute('purchase', 'e_march' . $i . '_price');
         /* autocomplete */
         $W1->set_attribute('price', 'e_march' . $i . '_price');
         /* via search */
         // name of the field with the TVA_ID
         $W1->set_attribute('tvaid', 'e_march' . $i . '_tva_id');
         // Add the callback function to filter the card on the jrn
         $W1->set_callback('filter_card');
         $W1->set_function('fill_data');
         $W1->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $W1->name);
         $W1->readonly = false;
         $array[$i]['quick_code'] = $W1->input();
         $array[$i]['bt'] = $W1->search();
         $array[$i]['hidden'] = '';
         // For computing we need some hidden field for holding the value
         if ($g_parameter->MY_TVA_USE == 'Y') {
             $array[$i]['hidden'] .= HtmlInput::hidden('tva_march' . $i, 0);
         }
         if ($g_parameter->MY_TVA_USE == 'Y') {
             $tvac = new INum('tvac_march' . $i);
         } else {
             $tvac = new IHidden('tvac_march' . $i);
         }
         $tvac->readOnly = 1;
         $tvac->value = 0;
         $array[$i]['tvac'] = $tvac->input();
         $htva = new INum('htva_march' . $i);
         $htva->readOnly = 1;
         $htva->value = 0;
         $array[$i]['htva'] = $htva->input();
         if ($g_parameter->MY_UPDLAB == 'Y') {
             $Span = new IText("e_march" . $i . "_label");
             $Span->css_size = "100%";
         } else {
             $Span = new ISpan("e_march" . $i . "_label");
         }
         $Span->value = $march_label;
         $Span->setReadOnly(false);
         // card's name, price
         //--
         $array[$i]['denom'] = $Span->input("e_march" . $i . "_label", $march_label);
         // price
         $Price = new INum();
         $Price->setReadOnly(false);
         $Price->size = 9;
         $Price->javascript = "onBlur='format_number(this);clean_tva({$i});compute_ledger({$i})'";
         $array[$i]['pu'] = $Price->input("e_march" . $i . "_price", $march_price);
         if ($g_parameter->MY_TVA_USE == 'Y') {
             // vat label
             //--
             $Tva = new ITva_Popup($ledger->db);
             $Tva->js = "onblur=\"format_number(this);onChange=clean_tva({$i});compute_ledger({$i})\"";
             $Tva->in_table = true;
             $Tva->set_attribute('compute', $i);
             $Tva->value = $march_tva_id;
             $array[$i]['tva'] = $Tva->input("e_march{$i}" . "_tva_id");
             // Tva_amount
             // price
             $Tva_amount = new INum();
             $Tva_amount->setReadOnly(false);
             $Tva_amount->size = 9;
             $Tva_amount->javascript = "onBlur='format_number(this);compute_ledger({$i})'";
             $array[$i]['amount_tva'] = $Tva_amount->input("e_march" . $i . "_tva_amount", $march_tva_amount);
         }
         // quantity
         //--
         $quant = isset(${"e_quant{$i}"}) ? ${"e_quant{$i}"} : "1";
         $Quantity = new INum();
         $Quantity->setReadOnly(false);
         $Quantity->size = 9;
         $Quantity->javascript = "onChange=format_number(this);clean_tva({$i});compute_ledger({$i})";
         $array[$i]['quantity'] = $Quantity->input("e_quant" . $i, $quant);
     }
     $f_type = _('Fournisseur');
     ob_start();
     require_once NOALYSS_INCLUDE . '/template/predf_ledger_detail.php';
     $r .= ob_get_contents();
     ob_end_clean();
     // Set correctly the REQUEST param for jrn_type
     $r .= HtmlInput::hidden('jrn_type', 'ACH');
     $r .= HtmlInput::button('add_item', _('Ajout article'), ' onClick="ledger_add_row()"');
     return $r;
 }
     $letter->get_letter();
 }
 // unlettered
 if ($_GET['histo'] == 2) {
     $letter->get_unletter();
 }
 if ($_GET['histo'] == 6) {
     $letter->get_letter_diff();
 }
 /* skip if nothing to display */
 if (count($letter->content) == 0) {
     continue;
 }
 $pdf->SetFont('DejaVuCond', '', 10);
 $fiche = new Fiche($cn, $row_fiche['f_id']);
 $pdf->Cell(0, 7, $fiche->strAttribut(ATTR_DEF_NAME) . " [" . $fiche->strAttribut(ATTR_DEF_QUICKCODE) . ":" . $fiche->strAttribut(ATTR_DEF_ACCOUNT) . "]", 1, 'C');
 $pdf->SetFont('DejaVuCond', '', 7);
 $pdf->Ln();
 $pdf->Cell($tab[0], 7, 'Date');
 $pdf->Cell($tab[1], 7, 'ref');
 $pdf->Cell($tab[2], 7, 'Internal');
 $pdf->Cell($tab[3], 7, 'Comm');
 $pdf->Cell($tab[4], 7, 'Montant', 0, 0, 'C');
 $pdf->Cell($tab[5], 7, 'Prog.', 0, 0, 'R');
 $pdf->Cell($tab[6], 7, 'Let.', 0, 0, 'R');
 $pdf->Cell($tab[7], 7, 'Diff. Let.', 0, 0, 'R');
 $pdf->ln();
 $amount_deb = 0;
 $amount_cred = 0;
 $prog = 0;
 for ($i = 0; $i < count($letter->content); $i++) {
 }
 // lettered
 if ($_GET['histo'] == 1) {
     $letter->get_letter();
 }
 // unlettered
 if ($_GET['histo'] == 2) {
     $letter->get_unletter();
 }
 /* skip if nothing to display */
 if (count($letter->content) == 0) {
     continue;
 }
 $pdf->SetFont('DejaVuCond', '', 10);
 $fiche = new Fiche($cn, $row_fiche['f_id']);
 $pdf->Cell(0, 7, $fiche->strAttribut(ATTR_DEF_NAME), 1, 1, 'C');
 $pdf->SetFont('DejaVuCond', '', 7);
 $pdf->Cell($tab[0], 7, 'Date');
 $pdf->Cell($tab[1], 7, 'ref');
 $pdf->Cell($tab[1], 7, 'Int.');
 $pdf->Cell($tab[2], 7, 'Comm');
 $pdf->Cell(40, 7, 'Montant', 0, 0, 'C');
 $pdf->Cell($tab[5], 7, 'Let.', 0, 0, 'R');
 $pdf->Cell($tab[6], 7, 'Som. Let.', 0, 0, 'R');
 $pdf->ln();
 $amount_deb = 0;
 $amount_cred = 0;
 for ($i = 0; $i < count($letter->content); $i++) {
     if ($i % 2 == 0) {
         $pdf->SetFillColor(220, 221, 255);
         $fill = 1;
echo th(_('Personnel'), 'style="text-align:right"');
echo th(_('Non ded'), 'style="text-align:right"');
if ($g_parameter->MY_TVA_USE == 'Y') {
    echo th(_('HTVA'), 'style="text-align:right"');
    echo th(_('TVA NP'), 'style="text-align:right"');
    echo th(_('TVA'), 'style="text-align:right"');
    echo th(_('TVAC'), 'style="text-align:right"');
} else {
    echo th(_('Total'), 'style="text-align:right"');
}
echo '</tr>';
for ($e = 0; $e < count($obj->det->array); $e++) {
    $row = '';
    $q = $obj->det->array[$e];
    $fiche = new Fiche($cn, $q['qp_fiche']);
    $view_card_detail = HtmlInput::card_detail($fiche->strAttribut(ATTR_DEF_QUICKCODE), "", ' class="line" ');
    $row = td($view_card_detail);
    $sym_tva = '';
    if ($g_parameter->MY_TVA_USE == 'Y' && $q['qp_vat_code'] != '') {
        /* retrieve TVA symbol */
        $tva = new Acc_Tva($cn, $q['qp_vat_code']);
        $tva->load();
        $sym_tva = h($tva->get_parameter('label'));
    }
    $input = new ISpan("e_march" . $q['j_id'] . "_label");
    $hidden = HtmlInput::hidden("j_id[]", $q['j_id']);
    $input->value = $fiche->strAttribut(ATTR_DEF_NAME);
    $row .= td($input->input() . $hidden);
    $row .= td($sym_tva, 'style="text-align:center"');
    $pu = 0;
    if ($q['qp_quantite'] != 0) {
 /**
  * Insert into stock_goods from ACH and VEN
  * @param type $p_array KEY : db => database conx, j_id => jrnx.j_id,goods=> f_id of the goods
  * 'quant' => quantity ,'dir'=> d or c (c for sales OUT and d for purchase IN),'repo'=>r_id of the
  * repository (stock_repository.r_id
  */
 static function insert_goods(&$p_cn, $p_array)
 {
     global $g_user;
     extract($p_array);
     if ($g_user->can_write_repo($repo) == false) {
         return false;
     }
     // Retrieve the good account for stock
     $code = new Fiche($p_cn);
     $code->get_by_qcode($goods);
     $code_marchandise = $code->strAttribut(ATTR_DEF_STOCK);
     if ($code_marchandise == NOTFOUND || $code_marchandise == '') {
         return false;
     }
     $exercice = $g_user->get_exercice();
     if ($exercice == 0) {
         throw new Exception('Annee invalide erreur');
     }
     $Res = $p_cn->exec_sql("insert into stock_goods (\n                            j_id,\n                            f_id,\n                            sg_code,\n                            sg_quantity,\n                            sg_type,sg_exercice,r_id ) values (\$1,\$2,\$3,\$4,\$5,\$6,\$7)", array($p_array['j_id'], $code->id, $code_marchandise, $p_array['quant'], $p_array['dir'], $exercice, $p_array['repo']));
     return $Res;
 }
Beispiel #22
0
            $aCard = Database::fetch_array($ret, $i);
            $oCard = new Fiche($cn, $aCard['f_id']);
            $solde = $oCard->get_solde_detail($filter);
            if ($solde['debit'] == 0 && $solde['credit'] == 0) {
                continue;
            }
            /* only not purged card */
            if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) {
                continue;
            }
            $class = $idx % 2 == 0 ? 'class="odd"' : 'class="even"';
            $idx++;
            $sum_cred = bcadd($sum_cred, $solde['credit']);
            $sum_deb = bcadd($sum_deb, $solde['debit']);
            $sum_solde = bcsub($sum_deb, $sum_cred);
            echo tr(td(HtmlInput::history_card($oCard->id, $oCard->strAttribut(ATTR_DEF_QUICKCODE))) . td($oCard->strAttribut(ATTR_DEF_NAME)) . td(HtmlInput::history_account($oCard->strAttribut(ATTR_DEF_ACCOUNT), $oCard->strAttribut(ATTR_DEF_ACCOUNT))) . td(nbm($solde['debit']), 'class="sorttable_numeric" sorttable_customkey="' . $solde['debit'] . '" style="text-align:right"') . td(nbm($solde['credit']), 'class="sorttable_numeric" sorttable_customkey="' . $solde['debit'] . '" style="text-align:right"') . td(nbm(abs($solde['solde'])), 'class="sorttable_numeric" sorttable_customkey="' . $solde['solde'] . '" style="text-align:right"') . td($solde['debit'] < $solde['credit'] ? 'C' : 'D', 'style="text-align:right"'), $class);
        }
        echo '<tfoot>';
        echo tr(td('') . td(_('Totaux')) . td('') . td(nbm($sum_deb), 'style="text-align:right"') . td(nbm($sum_cred), 'style="text-align:right"') . td(nbm(abs($sum_solde)), 'style="text-align:right"') . td($sum_deb < $sum_cred ? 'C' : 'D', 'style="text-align:right"'), ' class="highlight"');
        echo '</tfoot>';
        echo '</table>';
    }
    if ($allcard == 0) {
        echo $str_add_card;
    }
    echo $export_pdf;
    echo $export_csv;
    echo $export_print;
    return;
}
/***********************************************************************************************************************************
            $solde = $oCard->get_solde_detail($filter);
            if ($solde['debit'] == 0 && $solde['credit'] == 0) {
                continue;
            }
            /* only not purged card */
            if ($_GET['histo'] == 5 && $solde['solde'] == 0) {
                continue;
            }
            $side = '';
            if (bcsub($solde['credit'], $solde['debit']) < 0) {
                $side = 'Deb.';
            }
            if (bcsub($solde['credit'], $solde['debit']) > 0) {
                $side = 'Cred.';
            }
            printf('"%s";"%s";"%s";%s;%s;%s;"%s"', $oCard->strAttribut(ATTR_DEF_QUICKCODE), $oCard->strAttribut(ATTR_DEF_NAME), $oCard->strAttribut(ATTR_DEF_ACCOUNT), nb($solde['debit']), nb($solde['credit']), nb(abs($solde['solde'])), $side);
            printf("\n");
        }
    }
} else {
    // all card
    if ($allcard == 1) {
        $afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc");
    } else {
        $afiche[0] = array('fd_id' => $_REQUEST['cat']);
    }
    $fic = new Fiche($cn);
    for ($e = 0; $e < count($afiche); $e++) {
        $array = Fiche::get_fiche_def($cn, $afiche[$e]['fd_id'], 'name_asc');
        foreach ($array as $card) {
            $row = new Fiche($cn, $card['f_id']);
    $view_history = sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:view_history_account(\'%s\',\'%s\')" >%s</A>', $q[$e]['j_poste'], $gDossier, $q[$e]['j_poste']);
    $row .= td($view_history);
    if ($q[$e]['j_qcode'] != '') {
        $fiche = new Fiche($cn);
        $fiche->get_by_qcode($q[$e]['j_qcode']);
        $view_history = sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:view_history_card(\'%s\',\'%s\')" >%s</A>', $fiche->id, $gDossier, $q[$e]['j_qcode']);
    } else {
        $view_history = '';
    }
    $row .= td($view_history);
    if ($q[$e]['j_text'] == "") {
        if ($q[$e]['j_qcode'] != '') {
            // nom de la fiche
            $ff = new Fiche($cn);
            $ff->get_by_qcode($q[$e]['j_qcode']);
            $row .= td($ff->strAttribut(h(ATTR_DEF_NAME)));
        } else {
            // libellé du compte
            $name = $cn->get_value('select pcm_lib from tmp_pcmn where pcm_val=$1', array($q[$e]['j_poste']));
            $row .= td(h($name));
        }
    } else {
        $row .= td(h($q[$e]['j_text']));
    }
    $montant = td(nbm($q[$e]['j_montant']), 'class="num"');
    $row .= $q[$e]['j_debit'] == 't' ? $montant : td('');
    $row .= $q[$e]['j_debit'] == 'f' ? $montant : td('');
    $class = $e % 2 == 0 ? ' class="even"' : 'class="odd"';
    echo tr($row, $class);
}
?>
    function confirm($p_array, $p_summary = false)
    {
        global $g_parameter;
        extract($p_array);
        // we don't need to verify if we need only a feedback
        if (!$p_summary) {
            $this->verify($p_array);
        }
        $anc = null;
        // to show a select list for the analytic
        // if analytic is op (optionnel) there is a blank line
        bcscale(4);
        $client = new Fiche($this->db);
        $client->get_by_qcode($e_client, true);
        $client_name = h($client->getName() . ' ' . $client->strAttribut(ATTR_DEF_ADRESS) . ' ' . $client->strAttribut(ATTR_DEF_CP) . ' ' . $client->strAttribut(ATTR_DEF_CITY));
        $lPeriode = new Periode($this->db);
        if ($this->check_periode() == true) {
            $lPeriode->p_id = $period;
        } else {
            $lPeriode->find_periode($e_date);
        }
        $date_limit = $lPeriode->get_date_limit();
        $r = "";
        $r .= '<TABLE>';
        if ($p_summary) {
            $jr_id = $this->db->get_value('select jr_id from jrn where jr_internal=$1', array($this->internal));
            $r .= "<tr>";
            $r .= '<td>';
            $r .= _('Détail opération ');
            $r .= '</td>';
            $r .= '<td>';
            $r .= sprintf('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a>', $jr_id, dossier::id(), $this->internal);
            $r .= '</td>';
            $r .= "</tr>";
        }
        $r .= '<tr>';
        if (!$p_summary) {
            $r .= '<td>' . _('Numéro Pièce') . '</td><td>' . hb($e_pj) . '</td>';
        } else {
            if (strcmp($this->pj, $e_pj) != 0) {
                $r .= '<td>' . _('Numéro Pièce') . '</td><td>' . hb($this->pj) . '<span class="notice"> ' . _('Attention numéro pièce existante, elle a du être adaptée') . '</span></td>';
            } else {
                $r .= '<td>' . _('Numéro Pièce') . '</td><td>' . hb($this->pj) . '</td>';
            }
        }
        $r .= '</tr>';
        $r .= '<td> ' . _('Date') . '</td><td> ' . hb($e_date) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td>' . _('Echeance') . '</td><td> ' . hb($e_ech) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Période Comptable') . '</td><td> ' . hb($date_limit['p_start'] . '-' . $date_limit['p_end']) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Journal') . '</td><td> ' . hb($this->get_name()) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Libellé') . '</td><td> ' . hb($e_comm) . '</td>';
        $r .= '</tr>';
        $r .= '<tr>';
        $r .= '<tr>';
        $r .= '<td> ' . _('Fournisseur') . '</td><td> ' . hb($e_client . ':' . $client_name) . '</td>';
        $r .= '</tr>';
        $r .= '</table>';
        $r .= '<h2>' . _('Détail articles achetés') . '</h2>';
        $r .= '<p class="decale">';
        $r .= '<table class="result" >';
        $r .= '<TR>';
        $r .= "<th>" . _('Code') . "</th>";
        $r .= "<th>" . _('Dénomination') . "</th>";
        $r .= "<th style=\"text-align:right\">" . _('prix') . "</th>";
        $r .= "<th style=\"text-align:right\">" . _('quantité') . "</th>";
        if ($g_parameter->MY_TVA_USE == 'Y') {
            $r .= "<th style=\"text-align:right\">" . _('tva') . "</th>";
            $r .= '<th style="text-align:right"> ' . _('Montant TVA') . '</th>';
            $r .= '<th style="text-align:right">' . _('Montant HTVA') . '</th>';
            $r .= '<th style="text-align:right">' . _('Montant TVAC') . '</th>';
        } else {
            $r .= '<th style="text-align:right">' . _('Montant') . '</th>';
        }
        /* if we use the AC */
        if ($g_parameter->MY_ANALYTIC != 'nu') {
            $anc = new Anc_Plan($this->db);
            $a_anc = $anc->get_list();
            $x = count($a_anc);
            /* set the width of the col */
            $r .= '<th colspan="' . $x . '">' . _('Compt. Analytique') . '</th>';
            /* add hidden variables pa[] to hold the value of pa_id */
            $r .= Anc_Plan::hidden($a_anc);
        }
        $r .= '</tr>';
        $tot_amount = 0.0;
        $tot_tva = 0.0;
        //--
        // For each item
        //--
        for ($i = 0; $i < $nb_item; $i++) {
            $tot_row = 0;
            if (strlen(trim(${"e_march" . $i})) == 0) {
                continue;
            }
            /* retrieve information for card */
            $fiche = new Fiche($this->db);
            $fiche->get_by_qcode(${"e_march" . $i});
            if ($g_parameter->MY_UPDLAB == 'Y') {
                $fiche_name = h(${"e_march" . $i . "_label"});
            } else {
                $fiche_name = $fiche->strAttribut(ATTR_DEF_NAME);
            }
            $amount = bcmul(${"e_march" . $i . "_price"}, ${'e_quant' . $i});
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $idx_tva = ${"e_march" . $i . "_tva_id"};
                $oTva = new Acc_Tva($this->db);
                $oTva->set_parameter('id', $idx_tva);
                $oTva->load();
                $op = new Acc_Compute();
                $op->set_parameter("amount", $amount);
                $op->set_parameter('amount_vat_rate', $oTva->get_parameter('rate'));
                $op->compute_vat();
                $tva_computed = $op->get_parameter('amount_vat');
                //----- if tva_amount is not given we compute the vat ----
                if (strlen(trim(${'e_march' . $i . '_tva_amount'})) == 0) {
                    $tva_item = $op->get_parameter('amount_vat');
                } else {
                    $tva_item = round(${'e_march' . $i . '_tva_amount'}, 2);
                }
                if (isset($tva[$idx_tva])) {
                    $tva[$idx_tva] = bcadd($tva_item, $tva[$idx_tva]);
                } else {
                    $tva[$idx_tva] = $tva_item;
                }
            }
            $tot_amount = round(bcadd($tot_amount, $amount), 2);
            $tot_row = round(bcadd($tot_row, $amount), 2);
            $r .= '<tr>';
            $r .= '<td>';
            $r .= ${"e_march" . $i};
            $r .= '</td>';
            $r .= '<TD style="border-bottom:1px dotted grey;">';
            $r .= $fiche_name;
            $r .= '</td>';
            $r .= '<td class="num">';
            $r .= nbm(${"e_march" . $i . "_price"});
            $r .= '</td>';
            $r .= '<td class="num">';
            $r .= nbm(${"e_quant" . $i});
            $r .= '</td>';
            $both_side = 0;
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $r .= '<td class="num">';
                $r .= $oTva->get_parameter('label');
                $both_side = $oTva->get_parameter("both_side");
                if ($both_side == 0) {
                    $tot_row = bcadd($tot_row, $tva_item);
                    $tot_tva = round(bcadd($tva_item, $tot_tva), 2);
                }
                $r .= '</td>';
                /* warning if tva_computed and given are not the
                   same */
                $css_void_tva = $both_side == 1 ? 'style="text-decoration:line-through"' : '';
                if (bcsub($tva_item, $tva_computed) != 0 && !($tva_item == 0 && $both_side == 1)) {
                    $r .= '<td style="background-color:red" class="num" ' . $css_void_tva . '>';
                    $r .= HtmlInput::infobulle(28);
                    $r .= '<a href="#" class="error" style="display:inline" title="' . _("Attention Différence entre TVA calculée et donnée") . '">' . nbm($tva_item) . '<a>';
                } else {
                    $r .= '<td  class="num" ' . $css_void_tva . '>';
                    $r .= nbm($tva_item);
                }
                $r .= '</td>';
                $r .= '<td class="num"> ';
                $r .= nbm(round($amount, 2));
                $r .= '</td>';
            }
            $r .= '<td class="num">';
            $r .= nbm(round($tot_row, 2));
            $r .= '</td>';
            // encode the pa
            if ($g_parameter->MY_ANALYTIC != 'nu') {
                // show form
                $anc_op = new Anc_Operation($this->db);
                $null = $g_parameter->MY_ANALYTIC == 'op' ? 1 : 0;
                $r .= '<td>';
                $p_mode = $p_summary == false ? 1 : 0;
                $p_array['pa_id'] = $a_anc;
                /* op is the operation it contains either a sequence or a jrnx.j_id */
                $r .= HtmlInput::hidden('op[]=', $i);
                $r .= $anc_op->display_form_plan($p_array, $null, $p_mode, $i, $amount);
                $r .= '</td>';
            }
            $r .= '</tr>';
        }
        // Add the sum
        $decalage = $g_parameter->MY_TVA_USE == 'Y' ? '<td></td><td></td><td></td><td></td>' : '<td></td>';
        $tot = round(bcadd($tot_amount, $tot_tva), 2);
        $tot_tva = nbm($tot_tva);
        $tot = nbm($tot);
        $str_tot = _('Totaux');
        $tot_amount = nbm($tot_amount);
        $r .= <<<EOF
<tr class="highlight">
    {$decalage}            
     <td>
                {$str_tot}
     </td>
    <td class="num">
        {$tot_tva}
    </td>
    <td class="num">
        {$tot_amount}
    </td>
    <td class="num">
        {$tot}
    </td>
EOF;
        $r .= '</table>';
        $r .= '</p>';
        if ($g_parameter->MY_ANALYTIC != 'nu' && !$p_summary) {
            // use of AA
            $r .= '<input type="button" class="button" value="' . _('Vérifiez imputation analytique') . '" onClick="verify_ca(\'\');">';
        }
        $r .= !$p_summary ? '<div id="total_div_id" >' : '<div>';
        $r .= '<h2>Totaux</h2>';
        /* use VAT */
        if ($g_parameter->MY_TVA_USE == 'Y') {
            $r .= '<table>';
            $r .= '<tr><td>Total HTVA</td>';
            $r .= td(hb($tot_amount), 'class="num"');
            foreach ($tva as $i => $value) {
                $oTva->set_parameter('id', $i);
                $oTva->load();
                $r .= '<tr><td>  TVA ' . $oTva->get_parameter('label') . '</td>';
                $r .= td(hb(nbm($tva[$i])), 'class="num"');
            }
            $r .= '<tr>' . td(_('Total TVA')) . td(hb($tot_tva), 'class="num"');
            $r .= '<tr>' . td(_('Total TVAC')) . td(hb($tot), 'class="num"');
            $r .= '</table>';
        } else {
            $r .= '<br>Total ' . hb($tot);
        }
        $r .= '</div>';
        /*  Add hidden */
        $r .= HtmlInput::hidden('e_client', $e_client);
        $r .= HtmlInput::hidden('nb_item', $nb_item);
        $r .= HtmlInput::hidden('p_jrn', $p_jrn);
        if (isset($period)) {
            $r .= HtmlInput::hidden('period', $period);
        }
        $r .= HtmlInput::hidden('e_comm', $e_comm);
        $r .= HtmlInput::hidden('e_date', $e_date);
        $r .= HtmlInput::hidden('e_ech', $e_ech);
        $r .= HtmlInput::hidden('jrn_type', $jrn_type);
        $r .= HtmlInput::hidden('e_pj', $e_pj);
        $r .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
        $mt = microtime(true);
        $r .= HtmlInput::hidden('mt', $mt);
        $e_mp = isset($e_mp) ? $e_mp : 0;
        $r .= HtmlInput::hidden('e_mp', $e_mp);
        /* Paid by */
        /* if the paymethod is not 0 and if a quick code is given */
        for ($i = 0; $i < $nb_item; $i++) {
            $r .= HtmlInput::hidden("e_march" . $i, ${"e_march" . $i});
            if (isset(${"e_march" . $i . "_label"})) {
                $r .= HtmlInput::hidden("e_march" . $i . "_label", ${"e_march" . $i . "_label"});
            }
            $r .= HtmlInput::hidden("e_march" . $i . "_price", ${"e_march" . $i . "_price"});
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $r .= HtmlInput::hidden("e_march" . $i . "_tva_id", ${"e_march" . $i . "_tva_id"});
                $r .= HtmlInput::hidden('e_march' . $i . '_tva_amount', ${'e_march' . $i . '_tva_amount'});
            }
            $r .= HtmlInput::hidden("e_quant" . $i, ${"e_quant" . $i});
        }
        /**
         * 
         */
        if ($e_mp != 0 && strlen(trim(${'e_mp_qcode_' . $e_mp})) != 0) {
            $r .= HtmlInput::hidden('e_mp_qcode_' . $e_mp, ${'e_mp_qcode_' . $e_mp});
            $r .= HtmlInput::hidden('acompte', $acompte);
            $r .= HtmlInput::hidden('e_comm_paiement', $e_comm_paiement);
            /* needed for generating a invoice */
            $r .= HtmlInput::hidden('qcode_benef', ${'e_mp_qcode_' . $e_mp});
            $fname = new Fiche($this->db);
            $fname->get_by_qcode(${'e_mp_qcode_' . $e_mp});
            $r .= '<h2>' . _("Payé par") . " " . ${'e_mp_qcode_' . $e_mp} . " " . $fname->getName() . '</h2> ' . '<p class="decale">' . _('Déduction acompte ') . h($acompte) . '</p>' . _('Libellé :') . h($e_comm_paiement);
            $r .= '<br>';
            $r .= '<br>';
        }
        // check for upload piece
        return $r;
    }