コード例 #1
0
ファイル: anc_od.inc.php プロジェクト: Kloadut/noalyss_ynh
 * \brief Misc Operation for analytic accountancy
 *
 */
if (!defined('ALLOWED')) {
    die('Appel direct ne sont pas permis');
}
require_once NOALYSS_INCLUDE . '/class_ihidden.php';
require_once NOALYSS_INCLUDE . '/class_iselect.php';
require_once NOALYSS_INCLUDE . '/class_anc_account.php';
require_once NOALYSS_INCLUDE . '/class_anc_operation.php';
require_once NOALYSS_INCLUDE . '/class_anc_plan.php';
require_once NOALYSS_INCLUDE . '/class_anc_group_operation.php';
global $g_user;
$str_dossier = Dossier::get();
$pa = new Anc_Plan($cn);
$m = $pa->get_list();
if (!$m) {
    echo '<div style="float:left;width:60%;margin-left:20%"><h2 class="error">' . _('Aucun plan analytique défini') . '</h2></div>';
    return;
}
//----------------------------------------------------------------------
// show the left menu
//----------------------------------------------------------------------
echo '
<div class="content" >
<div class="menu2">
<table>
<tr>
<td  class="mtitle" >
<A class="mtitle" HREF="?ac=' . $_REQUEST['ac'] . '&new&' . $str_dossier . '"> ' . _('Nouveau') . ' </A>
</td>
コード例 #2
0
 function display_form_plan($p_array, $p_null, $p_mode, $p_seq, $p_amount, $p_id = '', $p_add_button = true)
 {
     if ($p_array != null) {
         extract($p_array);
     }
     $result = "";
     $plan = new Anc_Plan($this->db);
     $a_plan = $plan->get_list(" order by pa_id ");
     if (empty($a_plan)) {
         return "";
     }
     $table_id = "t" . $p_seq;
     $hidden = new IHidden();
     $readonly = $p_mode == 1 ? false : true;
     $result .= $hidden->input('amount_' . $table_id, $p_amount);
     if ($p_mode == 1) {
         $result .= '<table id="' . $p_id . $table_id . '">';
     } else {
         $result .= '<table>';
     }
     $result .= "<tr>" . $plan->header() . "<th>montant</th></tr>";
     /* compute the number of rows */
     $nb_row = isset($val[$p_seq]) ? count($val[$p_seq]) : 1;
     $count = 0;
     $remain = abs($p_amount);
     $ctrl_remain = "remain" . $this->in_div . $table_id;
     for ($i = 0; $i < $nb_row; $i++) {
         $result .= '<tr>';
         foreach ($a_plan as $r_plan) {
             $array = $this->db->make_array("select po_id as value," . " html_quote(po_name) as label from poste_analytique " . " where pa_id = " . $r_plan['id'] . " order by po_name", $p_null);
             $select = new ISelect("hplan[" . $p_seq . "][]", $array);
             $select->table = 0;
             // view only or editables
             if ($p_mode == 1) {
                 // editable
                 $select->readonly = false;
                 if (isset($hplan) && isset($hplan[$p_seq][$count])) {
                     $select->selected = $hplan[$p_seq][$count];
                 }
             } else {
                 if (isset($hplan) && isset($hplan[$p_seq][$count])) {
                     $select->selected = $hplan[$p_seq][$count];
                 }
                 // view only
                 $select->readOnly = true;
             }
             if ($p_mode == 1) {
                 $result .= '<td>' . $select->input() . '</td>';
             } else {
                 $result .= '<td>' . $select->display() . '</td>';
             }
             $count++;
         }
         $value = new INum();
         $value->javascript = 'onchange="format_number(this);anc_refresh_remain(\'' . $this->in_div . $table_id . '\',\'' . $p_seq . '\')"';
         $value->name = "val[" . $p_seq . "][]";
         $value->size = 6;
         $value->value = isset($val[$p_seq][$i]) ? $val[$p_seq][$i] : abs($p_amount);
         $value->readOnly = $p_mode == 1 ? false : true;
         $remain = bcsub($remain, $value->value);
         $result .= '<td>' . $value->input() . '</td>';
         $result .= "</tr>";
     }
     $result .= "</table>";
     if ($p_add_button && $p_mode == 1) {
         $style_remain = $remain == 0 ? 'style="color:green"' : ' style="color:red"';
         $result .= " Reste à imputer =  " . '<span class="remain" ' . $style_remain . ' id="' . $ctrl_remain . '">' . $remain . '</span>';
         // add a button to add a row
         $button = new IButton();
         $button->javascript = "add_row('" . $p_id . "{$table_id}',{$p_seq});";
         $button->name = "js" . $p_id . $p_seq;
         $button->label = _("Nouvelle ligne");
         $result .= "<br>" . $button->input();
         /**
          * Add a button for distribution key
          * 
          */
         $ledger = HtmlInput::default_value_post("p_jrn", 0);
         if ($ledger == 0) {
             $ledger = $this->db->get_value('select j_jrn_def from jrnx where j_id=$1', array($this->j_id));
         }
         $gDossier = Dossier::id();
         $button_key = new IButton();
         $button_key->javascript = "anc_key_choice(" . $gDossier . ",'" . $p_id . "{$table_id}',{$p_amount},'" . $ledger . "');";
         $button_key->name = "js" . $p_id . $p_seq;
         $button_key->label = _("Clef");
         $result .= $button_key->input();
     }
     return $result;
 }
コード例 #3
0
 /**
  * @brief show the result of the array to confirm
  * before inserting
  * @param$p_array array from the form
  * \return string
  */
 function confirm($p_array, $p_readonly = false)
 {
     global $g_parameter;
     $msg = array();
     if (!$p_readonly) {
         $msg = $this->verify($p_array);
     }
     $this->id = $p_array['p_jrn'];
     if (empty($p_array)) {
         return 'Aucun r&eacute;sultat';
     }
     $anc = null;
     extract($p_array);
     $lPeriode = new Periode($this->db);
     if ($this->check_periode() == true) {
         $lPeriode->p_id = $period;
     } else {
         $lPeriode->find_periode($e_date);
     }
     $total_deb = 0;
     $total_cred = 0;
     bcscale(2);
     $ret = "";
     if (!empty($msg)) {
         $ret .= $this->display_warning($msg, _("Attention : il vaut mieux utiliser les fiches que les postes comptables"));
     }
     $ret .= "<table >";
     $ret .= "<tr><td>" . _('Date') . " : </td><td>{$e_date}</td></tr>";
     /* display periode */
     $date_limit = $lPeriode->get_date_limit();
     $ret .= '<tr> ' . td(_('Période Comptable')) . td($date_limit['p_start'] . '-' . $date_limit['p_end']) . '</tr>';
     $ret .= "<tr><td>" . _('Libellé') . " </td><td>" . h($desc) . "</td></tr>";
     $ret .= "<tr><td>" . _('PJ Num') . " </td><td>" . h($e_pj) . "</td></tr>";
     $ret .= '</table>';
     $ret .= "<table class=\"result\">";
     $ret .= "<tr>";
     $ret .= "<th>" . _('Quick Code ou ');
     $ret .= _("Poste") . " </th>";
     $ret .= "<th style=\"text-align:left\"> " . _("Libellé") . " </th>";
     $ret .= "<th style=\"text-align:right\">" . _("Débit") . "</th>";
     $ret .= "<th style=\"text-align:right\">" . _("Crédit") . "</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 */
         $ret .= '<th colspan="' . $x . '" style="width:auto;text-align:center" >' . _('Compt. Analytique') . '</th>';
         /* add hidden variables pa[] to hold the value of pa_id */
         $ret .= Anc_Plan::hidden($a_anc);
     }
     $ret .= "</tr>";
     $ret .= HtmlInput::hidden('e_date', $e_date);
     $ret .= HtmlInput::hidden('desc', $desc);
     $ret .= HtmlInput::hidden('period', $lPeriode->p_id);
     $ret .= HtmlInput::hidden('e_pj', $e_pj);
     $ret .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
     $mt = microtime(true);
     $ret .= HtmlInput::hidden('mt', $mt);
     // For predefined operation
     $ret .= HtmlInput::hidden('e_comm', $desc);
     $ret .= HtmlInput::hidden('jrn_type', $this->get_type());
     $ret .= HtmlInput::hidden('p_jrn', $this->id);
     $ret .= HtmlInput::hidden('nb_item', $nb_item);
     if ($this->with_concerned == true) {
         $ret .= HtmlInput::hidden('jrn_concerned', $jrn_concerned);
     }
     $ret .= dossier::hidden();
     $count = 0;
     for ($i = 0; $i < $nb_item; $i++) {
         if ($p_readonly == true) {
             if (!isset(${'qc_' . $i})) {
                 ${'qc_' . $i} = '';
             }
             if (!isset(${'poste' . $i})) {
                 ${'poste' . $i} = '';
             }
             if (!isset(${'amount' . $i})) {
                 ${'amount' . $i} = '';
             }
         }
         $class = $i % 2 == 0 ? ' class="even" ' : ' class="odd" ';
         $ret .= "<tr {$class}> ";
         if (trim(${'qc_' . $i}) != "") {
             $oqc = new Fiche($this->db);
             $oqc->get_by_qcode(${'qc_' . $i}, false);
             $strPoste = $oqc->strAttribut(ATTR_DEF_ACCOUNT);
             $ret .= "<td>" . ${'qc_' . $i} . ' - ' . $oqc->strAttribut(ATTR_DEF_NAME) . HtmlInput::hidden('qc_' . $i, ${'qc_' . $i}) . '</td>';
         }
         if (trim(${'qc_' . $i}) == "" && trim(${'poste' . $i}) != "") {
             $oposte = new Acc_Account_Ledger($this->db, ${'poste' . $i});
             $strPoste = $oposte->id;
             $ret .= "<td>" . h(${"poste" . $i} . " - " . $oposte->get_name()) . HtmlInput::hidden('poste' . $i, ${'poste' . $i}) . '</td>';
         }
         if (trim(${'qc_' . $i}) == "" && trim(${'poste' . $i}) == "") {
             continue;
         }
         $ret .= "<td>" . h(${"ld" . $i}) . HtmlInput::hidden('ld' . $i, ${'ld' . $i});
         $ret .= isset(${"ck{$i}"}) ? HtmlInput::hidden('ck' . $i, ${'ck' . $i}) : "";
         $ret .= "</td>";
         if (isset(${"ck{$i}"})) {
             $ret .= "<td class=\"num\">" . nbm(${"amount" . $i}) . HtmlInput::hidden('amount' . $i, ${'amount' . $i}) . "</td>" . td("");
             $total_deb = bcadd($total_deb, ${'amount' . $i});
         } else {
             $ret .= td("") . "<td class=\"num\">" . nbm(${"amount" . $i}) . HtmlInput::hidden('amount' . $i, ${'amount' . $i}) . "</td>";
             $total_cred = bcadd($total_cred, ${"amount" . $i});
         }
         /*$ret.="<td>";
         		$ret.=(isset(${"ck$i"})) ? HtmlInput::hidden('ck' . $i, ${'ck' . $i}) : "";
         		$ret.="</td>";*/
         // CA
         if ($g_parameter->MY_ANALYTIC != 'nu') {
             if (preg_match("/^[6,7]+/", $strPoste) == 1) {
                 // show form
                 $op = new Anc_Operation($this->db);
                 $null = $g_parameter->MY_ANALYTIC == 'op' ? 1 : 0;
                 $p_array['pa_id'] = $a_anc;
                 /* op is the operation it contains either a sequence or a jrnx.j_id */
                 $ret .= HtmlInput::hidden('op[]=', $i);
                 $ret .= '<td style="text-align:center">';
                 $read = $p_readonly == true ? 0 : 1;
                 $ret .= $op->display_form_plan($p_array, $null, $read, $count, round(${'amount' . $i}, 2));
                 $ret .= '</td>';
                 $count++;
             }
         }
         $ret .= "</tr>";
     }
     $ret .= tr(td('') . td(_('Totaux')) . td($total_deb, 'class="num"') . td($total_cred, 'class="num"'), 'class="highlight"');
     $ret .= "</table>";
     if ($g_parameter->MY_ANALYTIC != 'nu' && $p_readonly == false) {
         $ret .= '<input type="button" class="button" value="' . _('verifie Imputation Analytique') . '" onClick="verify_ca(\'\');">';
     }
     return $ret;
 }
コード例 #4
0
    echo th('');
}
echo th(_('Prix/Un.'), 'style="text-align:right"');
echo th(_('Quantité'), 'style="text-align:right"');
echo th(_('Non ded'), 'style="text-align:right"');
if ($owner->MY_TVA_USE == 'Y') {
    echo th(_('HTVA'), 'style="text-align:right"');
    echo th(_('TVA ND'), '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"');
}
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'] != '') {
コード例 #5
0
 function get_from_array($p_array)
 {
     $Plan = new Anc_Plan($this->db);
     $aPlan = $Plan->get_list();
     for ($i = 0; $i < $p_array['nbrow']; $i++) {
         foreach ($aPlan as $d) {
             $idx = $d['id'];
             $p = new Anc_Operation($this->db);
             $p->oa_amount = $p_array["pamount{$i}"];
             $p->oa_description = $p_array["pdesc"];
             $p->oa_date = $p_array['pdate'];
             $p->j_id = 0;
             $p->oa_debit = isset($p_array["pdeb{$i}"]) ? 't' : 'f';
             $p->oa_group = 0;
             $p->po_id = $p_array["pop{$i}" . "plan" . $idx];
             $p->pa_id = $idx;
             $this->a_operation[] = clone $p;
         }
     }
 }
コード例 #6
0
ファイル: anc_pa.inc.php プロジェクト: Kloadut/noalyss_ynh
        // ---> montre form pour ajouter po
        $ret .= HtmlInput::button_anchor(_('Ajout'), "?ac=" . $_REQUEST['ac'] . "&sa=po_add&pa_id=" . $_GET['pa_id'] . "&" . $str_dossier, '', '', 'smallbutton');
        $href = http_build_query(array('ac' => $_REQUEST['ac'], 'gDossier' => $_REQUEST['gDossier']));
        $ret .= '<a style="display:inline" class="smallbutton" href="do.php?' . $href . '">' . _('Retour') . '</a>';
        $ret .= '</div>';
    }
} else {
    $sa = "anc_menu";
}
//---------------------------------------------------------------------------
// Show lmenu
//
//---------------------------------------------------------------------------
if ($sa == 'anc_menu') {
    $obj = new Anc_Plan($cn);
    $list = $obj->get_list();
    if (empty($list)) {
        echo '<div class="content">';
        echo '<TABLE>';
        echo '<TR><TD class="vert_mtitle">';
        echo '<a href="?ac=' . $_REQUEST['ac'] . '&sa=add_pa&' . $str_dossier . '">' . _("Ajout d'un plan comptable") . '</a>';
        echo '</TD></TR>';
        echo '</TABLE>';
        echo '</div>';
        if (!isset($_REQUEST['sa'])) {
            echo '<div class="notice">' . _("Aucun plan analytique n'est défini") . '</div>';
        }
    } else {
        echo '<div class="content">';
        echo '<table class="vert_mtitle">';
        if ($obj->isAppend() == true) {
コード例 #7
0
echo th(_('Quantité'), 'style="text-align:right"');
if ($owner->MY_TVA_USE == 'Y') {
    echo th(_('Taux TVA'), 'style="text-align:right"');
} else {
    echo th('');
}
if ($owner->MY_TVA_USE == 'Y') {
    echo th(_('HTVA'), '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"');
}
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['qs_fiche']);
    $qcode = $fiche->strAttribut(ATTR_DEF_QUICKCODE);
    $view_card_detail = HtmlInput::card_detail($qcode, "", ' class="line" ');
    $row .= td($view_card_detail);
    if ($owner->MY_UPDLAB == 'Y') {
        $l_lib = $q['j_text'] == '' ? $fiche->strAttribut(ATTR_DEF_NAME) : $q['j_text'];
コード例 #8
0
    function confirm($p_array, $p_summary = false)
    {
        global $g_parameter;
        extract($p_array);
        // don't need to verify for a summary
        if (!$p_summary) {
            $this->verify($p_array);
        }
        $anc = null;
        // to show a select list for the analytic & VAT USE
        // 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 = $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 .= '<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 .= '<td> ' . _('Client') . '</td><td> ' . hb($e_client . ':' . $client_name) . '</td>';
        $r .= '</tr>';
        $r .= '</table>';
        $r .= '<h2>' . _('Détail articles vendus') . '</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 ($i = 0; $i < $nb_item; $i++) {
            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);
            }
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $oTva = new Acc_Tva($this->db);
                $idx_tva = ${"e_march" . $i . "_tva_id"};
                $oTva->set_parameter('id', $idx_tva);
                $oTva->load();
            }
            $op = new Acc_Compute();
            $amount = bcmul(${"e_march" . $i . "_price"}, ${'e_quant' . $i});
            $op->set_parameter("amount", $amount);
            if ($g_parameter->MY_TVA_USE == 'Y') {
                $op->set_parameter('amount_vat_rate', $oTva->get_parameter('rate'));
                $op->compute_vat();
                $tva_computed = $op->get_parameter('amount_vat');
                $tva_item = ${"e_march" . $i . "_tva_amount"};
                if (isset($tva[$idx_tva])) {
                    $tva[$idx_tva] += $tva_item;
                } else {
                    $tva[$idx_tva] = $tva_item;
                }
                $tot_tva = round(bcadd($tva_item, $tot_tva), 2);
            }
            $tot_amount = round(bcadd($tot_amount, $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');
                $r .= '</td>';
                $both_side = $oTva->get_parameter("both_side");
                /* warning if tva_computed and given are not the
                   same */
                if (bcsub($tva_item, $tva_computed) != 0 && !($tva_item == 0 && $both_side == 1)) {
                    $r .= '<td style="background-color:red" class="num">';
                    $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">';
                    $r .= nbm($tva_item);
                }
                $r .= '</td>';
                $r .= '<td class="num">';
                $r .= nbm($amount);
                $r .= '</td>';
                $tot_row = bcadd($tva_item, $amount);
                $r .= td(nbm($tot_row), 'class="num"');
            } else {
                $r .= '<td class="num">';
                $r .= nbm($amount);
                $r .= '</td>';
            }
            // encode the pa
            if ($g_parameter->MY_ANALYTIC != 'nu') {
                // use of AA
                // 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>';
        }
        // end loop item
        //
        // 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);
        $mt = microtime(true);
        $r .= HtmlInput::hidden('mt', $mt);
        if (isset($period)) {
            $r .= HtmlInput::hidden('period', $period);
        }
        /* \todo comment les types hidden gérent ils des contenus avec des quotes, double quote ou < > ??? */
        $r .= HtmlInput::hidden('e_comm', $e_comm);
        $r .= HtmlInput::hidden('e_date', $e_date);
        $r .= HtmlInput::hidden('e_ech', $e_ech);
        $r .= HtmlInput::hidden('e_pj', $e_pj);
        $r .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
        $e_mp = isset($e_mp) ? $e_mp : 0;
        $r .= HtmlInput::hidden('e_mp', $e_mp);
        if (isset($repo)) {
            // Show the available repository
            $r .= $this->select_depot($p_summary, $repo);
        }
        /* if the paymethod is not 0 and if a quick code is given */
        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 .= HtmlInput::hidden('jrn_type', $jrn_type);
        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});
        }
        return $r;
    }
コード例 #9
0
 public function confirm($p_array, $p_nothing = 0)
 {
     global $g_parameter, $g_user;
     $r = "";
     bcscale(2);
     extract($p_array);
     $pPeriode = new Periode($this->db);
     if ($this->check_periode() == true) {
         $pPeriode->p_id = $periode;
     } else {
         if (isDate($e_date) != null) {
             $pPeriode->find_periode($e_date);
         } else {
             $pPeriode->p_id = $g_user->get_periode();
         }
     }
     list($l_date_start, $l_date_end) = $pPeriode->get_date_limit();
     $exercice = $pPeriode->get_exercice();
     $r .= '';
     $r .= '<fieldset><legend>Banque, caisse </legend>';
     $r .= '<div id="jrn_name_div">';
     $r .= '<h2 id="jrn_name" style="display:inline">' . $this->get_name() . '</h2>';
     $r .= '</div>';
     $r .= '<TABLE  width="100%">';
     //  Date
     //--
     $r .= "<tr>";
     if ($chdate == 1) {
         $r .= '<td> Date : </td><td>' . $e_date;
     }
     // Periode
     //--
     $r .= "<td>";
     $r .= "Période comptable </td><td>";
     $r .= $l_date_start . ' - ' . $l_date_end;
     $r .= "</td>";
     $r .= "</tr>";
     // Ledger (p_jrn)
     //--
     $r .= '<tr>';
     $r .= '<td> Journal </td>';
     $this->id = $p_jrn;
     $r .= '<td>';
     $r .= h($this->get_name());
     $r .= '</td>';
     $r .= '</tr>';
     //retrieve bank name
     $bk_id = $this->get_bank();
     $fBank = new Fiche($this->db, $bk_id);
     $e_bank_account_label = $this->get_bank_name();
     $filter_year = "  j_tech_per in (select p_id from parm_periode where  p_exercice='" . $exercice . "')";
     $acc_account = new Acc_Account_Ledger($this->db, $fBank->strAttribut(ATTR_DEF_ACCOUNT));
     $asolde = $acc_account->get_solde_detail($filter_year);
     $deb = $asolde['debit'];
     $cred = $asolde['credit'];
     $solde = bcsub($deb, $cred);
     $new_solde = $solde;
     $r .= "<TR><td colspan=\"4\"> Banque ";
     $r .= $e_bank_account_label;
     $r .= "</TABLE>";
     $r .= '</fieldset>';
     $r .= '<div class="myfieldset"><h1 class="legend">Extrait de compte</h1>';
     //--------------------------------------------------
     // Saldo begin end
     //-------------------------------------------------
     $r .= '<table>';
     $r .= '<tr>';
     // Extrait
     //--
     $r .= tr('<td> Numéro d\'extrait</td>' . td(h($e_pj)));
     $r .= '<tr><td >Solde début extrait </td>';
     $r .= '<td style="num">' . nbm($first_sold) . '</td></tr>';
     $r .= '<tr><td>Solde fin extrait </td>';
     $r .= '<td style="num">' . nbm($last_sold) . '</td></tr>';
     $r .= '</table>';
     $r .= '<h1 class="legend">Opérations financières</h1>';
     //--------------------------------------------------
     // financial operation
     //-------------------------------------------------
     $r .= '<TABLE style="width:100%" id="fin_item">';
     $r .= "<TR>";
     if ($chdate == 2) {
         $r .= '<th>Date</th>';
     }
     $r .= "<th style=\"width:auto;text-align:left\" colspan=\"2\">Nom</TH>";
     $r .= "<th style=\"text-align:left\" >Commentaire</TH>";
     $r .= "<th style=\"text-align:right\">Montant</TH>";
     $r .= '<th colspan="2"> Op. Concern&eacute;e(s)</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>";
     // Parse each " tiers"
     $tot_amount = 0;
     //--------------------------------------------------
     // For each items
     //--------------------------------------------------
     for ($i = 0; $i < $nb_item; $i++) {
         $tiers = isset(${"e_other" . $i}) ? ${"e_other" . $i} : "";
         if (strlen(trim($tiers)) == 0) {
             continue;
         }
         $tiers_label = "";
         $tiers_amount = round(${"e_other{$i}" . "_amount"}, 2);
         $tot_amount = bcadd($tot_amount, $tiers_amount);
         $tiers_comment = h(${"e_other{$i}" . "_comment"});
         // If $tiers has a value
         $fTiers = new Fiche($this->db);
         $fTiers->get_by_qcode($tiers);
         $tiers_label = $fTiers->strAttribut(ATTR_DEF_NAME);
         $r .= "<TR>";
         if ($chdate == 2) {
             $r .= td(${"dateop" . $i});
         }
         $r .= "<td>" . ${'e_other' . $i} . "</TD>";
         // label
         $r .= '<TD style="width:25%;border-bottom:1px dotted grey;">';
         $r .= $fTiers->strAttribut(ATTR_DEF_NAME);
         $r .= '</td>';
         // Comment
         $r .= '<td style="width:40%">' . $tiers_comment . '</td>';
         // amount
         $r .= '<td class="num">' . nbm($tiers_amount) . '</td>';
         // concerned
         $r .= '<td style="text-align:center">';
         if (${"e_concerned" . $i} != '') {
             $jr_internal = $this->db->get_array("select jr_internal from jrn where jr_id in (" . ${"e_concerned" . $i} . ")");
             $comma = "";
             for ($x = 0; $x < count($jr_internal); $x++) {
                 $r .= $comma . HtmlInput::detail_op(${"e_concerned" . $i}, $jr_internal[$x]['jr_internal']);
                 $comma = " , ";
             }
         }
         $r .= '</td>';
         // encode the pa
         if ($g_parameter->MY_ANALYTIC != 'nu' && preg_match("/^[6,7]/", $fTiers->strAttribut(ATTR_DEF_ACCOUNT)) == 1) {
             // show form
             $anc_op = new Anc_Operation($this->db);
             $null = $g_parameter->MY_ANALYTIC == 'op' ? 1 : 0;
             $r .= '<td>';
             $p_mode = 1;
             $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, $tiers_amount);
             $r .= '</td>';
         }
         $r .= '</TR>';
     }
     $r .= "</TABLE>";
     // saldo
     $r .= '<br>Ancien solde = ' . $solde;
     $new_solde += $tot_amount;
     $r .= '<br>Nouveau solde = ' . $new_solde;
     $r .= '<br>Difference =' . $tot_amount;
     // check for upload piece
     $file = new IFile();
     $r .= "<br>Ajoutez une pi&egrave;ce justificative ";
     $r .= $file->input("pj", "");
     $r .= '</div>';
     //--------------------------------------------------
     // Hidden variables
     //--------------------------------------------------
     $r .= dossier::hidden();
     $r .= HtmlInput::hidden('p_jrn', $this->id);
     $r .= HtmlInput::hidden('nb_item', $nb_item);
     $r .= HtmlInput::hidden('last_sold', $last_sold);
     $r .= HtmlInput::hidden('first_sold', $first_sold);
     $r .= HtmlInput::hidden('e_pj', $e_pj);
     $r .= HtmlInput::hidden('e_pj_suggest', $e_pj_suggest);
     $r .= HtmlInput::hidden('e_date', $e_date);
     $mt = microtime(true);
     $r .= HtmlInput::hidden('mt', $mt);
     if (isset($periode)) {
         $r .= HtmlInput::hidden('periode', $periode);
     }
     $r .= dossier::hidden();
     $r .= HtmlInput::hidden('sa', 'n', 'chdate');
     for ($i = 0; $i < $nb_item; $i++) {
         $tiers = isset(${"e_other" . $i}) ? ${"e_other" . $i} : "";
         $r .= HtmlInput::hidden('e_other' . $i, $tiers);
         $r .= HtmlInput::hidden('e_other' . $i, $tiers);
         $r .= HtmlInput::hidden('e_other' . $i . '_comment', ${'e_other' . $i . '_comment'});
         $r .= HtmlInput::hidden('e_other' . $i . '_amount', ${'e_other' . $i . '_amount'});
         $r .= HtmlInput::hidden('e_concerned' . $i, ${'e_concerned' . $i});
         $r .= HtmlInput::hidden('dateop' . $i, ${'dateop' . $i});
         $r .= HtmlInput::hidden('chdate', $chdate);
     }
     return $r;
 }