Example #1
0
 /**
  * Tests Database->fetch_all()
  */
 public function testFetch_all()
 {
     $obj = $this->Database->query('select * from content_pages');
     $result = $this->Database->fetch_all($obj);
     if (count($result) < 2) {
         $this->fail();
     }
 }
 function load()
 {
     $filter = $this->set_sql_filter();
     // sum debit
     $sql = "select m.po_id,sum(deb) as sum_deb,sum(cred) as sum_cred,";
     $sql .= " po_name||'  '||coalesce(po_description,'') as po_name";
     $sql .= " from ";
     $sql .= " (select po_id,case when oa_debit='t' then oa_amount else 0 end as deb,";
     $sql .= "case when oa_debit='f' then oa_amount else 0 end as cred ";
     $sql .= " from operation_analytique join poste_analytique using(po_id)";
     $sql .= empty($filter) == false ? " where " . $filter : "";
     $sql .= " ) as m join poste_analytique using (po_id)";
     $sql .= " where pa_id=" . $this->pa_id;
     $sql .= " group by po_id,po_name,po_description";
     $sql .= " order by po_id";
     $res = $this->db->exec_sql($sql);
     if (Database::num_row($res) == 0) {
         $this->has_data = 0;
         return null;
     }
     $a = array();
     $count = 0;
     $array = Database::fetch_all($res);
     foreach ($array as $row) {
         $a[$count]['po_id'] = $row['po_id'];
         $a[$count]['sum_deb'] = $row['sum_deb'];
         $a[$count]['sum_cred'] = $row['sum_cred'];
         $a[$count]['po_name'] = $row['po_name'];
         $a[$count]['solde'] = abs($row['sum_deb'] - $row['sum_cred']);
         $a[$count]['debit'] = $row['sum_deb'] > $row['sum_cred'] ? "debit" : "credit";
         $count++;
     }
     $this->has_data = $count;
     return $a;
 }
 function myList()
 {
     $s = dossier::get();
     $sql = "select md_id,md_name,md_affect,dt_value from document_modele join document_type on(dt_id=md_type) order by md_name";
     $Res = $this->cn->exec_sql($sql);
     $all = Database::fetch_all($Res);
     $r = '';
     if (Database::num_row($Res) != 0) {
         $r .= '<p><form method="post">';
         $r .= dossier::hidden();
         $r .= "<table>";
         $r .= "<tr> ";
         $r .= th(_('Nom'));
         $r .= th(_('Catégorie'));
         $r .= th(_('Affect.'));
         $r .= th(_('Fichier'));
         $r .= th(_('Effacer'));
         $r .= "</tr>";
         foreach ($all as $row) {
             $r .= "<tr>";
             $r .= "<td>";
             $r .= h($row['md_name']);
             $r .= "</td>";
             $r .= "<td>";
             $r .= $row['dt_value'];
             $r .= "</td>";
             $r .= td(h($row['md_affect']));
             $r .= "<td>";
             $r .= '<A HREF="show_document_modele.php?md_id=' . $row['md_id'] . '&' . $s . '">Document</a>';
             $r .= "</td>";
             $r .= "<TD>";
             $c = new ICheckBox();
             $c->name = "dm_remove_" . $row['md_id'];
             $r .= $c->input();
             $r .= "</td>";
             $r .= td(HtmlInput::detail_modele_document($row['md_id'], 'Modifier'));
             $r .= "</tr>";
         }
         $r .= "</table>";
         // need hidden parameter for subaction
         $a = new IHidden();
         $a->name = "sa";
         $a->value = "rm_template";
         $r .= $a->input();
         $r .= HtmlInput::submit("rm_template", "Effacer la sélection");
     }
     $b = new IButton('show');
     $b->label = "Ajout d'un document";
     $b->javascript = "\$('add_modele').style.display='block';new Draggable('add_modele',{starteffect:function(){\n                      new Effect.Highlight(obj.id,{scroll:window,queue:'end'});}});";
     $r .= $b->input();
     $r .= "</form></p>";
     return $r;
 }
 function load_all()
 {
     $sql = "select * from parm_code order by p_code";
     $Res = $this->db->exec_sql($sql);
     $r = Database::fetch_all($Res);
     $idx = 0;
     $array = array();
     if ($r === false) {
         return null;
     }
     foreach ($r as $row) {
         $o = new Acc_Parm_Code($this->db, $row['p_code']);
         $array[$idx] = $o;
         $idx++;
     }
     return $array;
 }
 function LoadAll()
 {
     $sql = "select * from fiche_def_ref order by frd_id";
     $Res = $this->db->exec_sql($sql);
     $all = Database::fetch_all($Res);
     if ($Res == false) {
         return array();
     }
     $idx = 0;
     $array = array();
     foreach ($all as $row) {
         $o = new Fiche_Def_Ref($this->db);
         foreach ($this->attribut as $value) {
             $o->{$value} = $row[$value];
         }
         $array[$idx] = $o;
         $idx++;
     }
     return $array;
 }
Example #6
0
         foreach ($a_lob as $lob) {
             $cn_mod->lo_unlink($lob['loid']);
         }
     }
 }
 if (isset($_POST['CARD'])) {
     $Res = $cn_mod->exec_sql("delete from  fiche_detail");
     $Res = $cn_mod->exec_sql("delete from   fiche");
     $Res = $cn_mod->exec_sql("delete from action_gestion");
     $Res = $cn_mod->exec_sql("delete from document");
     $Res = $cn_mod->exec_sql("delete from document_modele");
     $Res = $cn_mod->exec_sql("delete from op_predef");
     // Remove lob file
     $Res = $cn_mod->exec_sql("select distinct loid from pg_largeobject");
     if (Database::num_row($Res) != 0) {
         $a_lob = Database::fetch_all($Res);
         foreach ($a_lob as $lob) {
             $cn_mod->lo_unlink($lob['loid']);
         }
     }
 }
 if (isset($_POST['CANAL'])) {
     $Res = $cn_mod->exec_sql('delete from poste_analytique');
     $Res = $cn_mod->exec_sql('delete from plan_analytique');
 }
 if (isset($_POST['PLUGIN'])) {
     $a_schema = $cn_mod->get_array("\n                select nspname from pg_namespace \n                where\n                nspname not like 'pg_%'\n                and nspname not in ('information_schema','public','comptaproc')\n                    ");
     $nb_schema = count($a_schema);
     for ($i = 0; $i < $nb_schema; $i++) {
         $cn_mod->exec_sql(" drop schema " . $a_schema[$i]['nspname'] . " cascade");
     }
Example #7
0
 function VatListing($p_year)
 {
     $cond_sql = " and   A.j_date = B.j_date and extract(year from A.j_date) ='{$p_year}'";
     /* List of customer  */
     $aCustomer = $this->cn->get_array('select f_id,name,quick_code,tva_num,poste_comptable from vw_client ' . " where tva_num !='' ");
     /* Use the code */
     // BASE ACCOUNT
     // for belgium
     $s = new Acc_Parm_Code($this->cn, 'VENTE');
     $s->load();
     $SOLD = $s->p_value;
     $c = new Acc_Parm_Code($this->cn, 'CUSTOMER');
     $c->load();
     $CUSTOMER = $c->p_value;
     $t = new Acc_Parm_Code($this->cn, 'COMPTE_TVA');
     $t->load();
     $TVA = $t->p_value;
     $a_Res = array();
     /* for each customer compute VAT, Amount...*/
     foreach ($aCustomer as $l) {
         // Seek the customer
         //---
         $customer = $l['quick_code'];
         $a_Res[$customer]['name'] = $l['name'];
         $a_Res[$customer]['vat_number'] = $l['tva_num'];
         $a_Res[$customer]['amount'] = 0;
         $a_Res[$customer]['tva'] = 0;
         $a_Res[$customer]['poste_comptable'] = $l['poste_comptable'];
         /* retrieve only operation of sold and vat */
         // Get all the sell operation
         //----
         $sql = "select distinct j_grpt\n                 from\n                 jrnx as A\n                 join jrnx as B using (j_grpt)\n                 where\n                 A.j_qcode = '" . $l['quick_code'] . "' and\n                 B.j_poste::text like '" . $SOLD . "%'\n                 {$cond_sql}\n                 ";
         $Res = $this->cn->exec_sql($sql);
         // Foreach operation
         // where 7% or tva account are involved
         // and store the result in an array (a_Res)
         //---
         for ($i = 0; $i < Database::num_row($Res); $i++) {
             // Get each row
             //---
             $row1 = Database::fetch_array($Res, $i);
             // select the operation
             //----
             $Res2 = $this->cn->exec_sql("select j_poste,j_montant,j_debit from jrnx where j_grpt=" . $row1['j_grpt']);
             $a_row = Database::fetch_all($Res2);
             // Store the amount in the array
             //---
             foreach ($a_row as $e) {
                 $amount = 0;
                 $tva = 0;
                 if (substr($e['j_poste'], 0, strlen($SOLD)) === $SOLD) {
                     $amount = $e['j_debit'] == 'f' ? $e['j_montant'] : $e['j_montant'] * -1;
                 }
                 if (substr($e['j_poste'], 0, strlen($TVA)) === $TVA) {
                     $tva = $e['j_debit'] == 'f' ? $e['j_montant'] : $e['j_montant'] * -1;
                 }
                 // store sold
                 //---
                 $a_Res[$customer]['amount'] = isset($a_Res[$customer]['amount']) ? $a_Res[$customer]['amount'] : 0;
                 $a_Res[$customer]['amount'] += $amount;
                 // store vat
                 //---
                 $a_Res[$customer]['tva'] = isset($a_Res[$customer]['tva']) ? $a_Res[$customer]['tva'] : 0;
                 $a_Res[$customer]['tva'] += $tva;
                 // store customef info
                 //---
                 $a_Res[$customer]['customer'] = $customer;
             }
         }
         // foreach $a
     }
     // foreach ( customer)
     return $a_Res;
 }
Example #8
0
 function load()
 {
     $sql = "select opd_id,opd_poste,opd_amount,opd_comment,opd_debit" . " from op_predef_detail where od_id=" . $this->operation->od_id . " order by opd_id";
     $res = $this->db->exec_sql($sql);
     $array = Database::fetch_all($res);
     return $array;
 }
 function get_jrnx_detail()
 {
     global $g_user;
     $filter_sql = $g_user->get_ledger_sql('ALL', 3);
     $filter_sql = str_replace('jrn_def_id', 'jr_def_id', $filter_sql);
     if ($this->jr_id == 0) {
         return;
     }
     $sql = " select  jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,\n             vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id " . " from jrnx join jrn on (jr_grpt_id=j_grpt)\n             join tmp_pcmn on (j_poste=pcm_val)\n             left join vw_fiche_attr on (j_qcode=quick_code)\n             where\n             jr_id=\$1 and {$filter_sql} order by j_debit desc";
     $res = $this->db->exec_sql($sql, array($this->jr_id));
     if (Database::num_row($res) == 0) {
         return array();
     }
     $all = Database::fetch_all($res);
     return $all;
 }
Example #10
0
 function myList()
 {
     $sql = " select ga_id,groupe_analytique.pa_id,pa_name,ga_description " . " from groupe_analytique " . " join plan_analytique using (pa_id)";
     $r = $this->db->exec_sql($sql);
     $array = Database::fetch_all($r);
     $res = array();
     if (!empty($array)) {
         foreach ($array as $m) {
             $obj = new Anc_Group($this->db);
             $obj->get_from_array($m);
             $obj->pa_name = $m['pa_name'];
             $res[] = clone $obj;
         }
     }
     return $res;
 }
 function get_balance($p_from, $p_to, $p_plan_id)
 {
     // for the operation connected to jrnx
     $cond = sql_filter_per($this->db, $p_from, $p_to, 'p_id', 'j_date');
     $sql = "select oa_id, po_id, oa_amount, oa_debit, j_date from jrnx join operation_analytique using (j_id)\n             join poste_analytique using (po_id)\n             where\n             {$cond} and j_id is not null and pa_id={$p_plan_id}";
     // OD
     $cond = sql_filter_per($this->db, $p_from, $p_to, 'p_id', 'oa_date');
     $sql = "union select oa_id, po_id, oa_amount, oa_debit,oa_date from\n             operation_analytique\n             join poste_analytique using (po_id)\n             where j_id is null and\n             {$cond} and pa_id={$p_plan_id} ";
     try {
         $res = $this->db->exec_sql($sql);
         $array = Database::fetch_all($res);
     } catch (Exception $e) {
         var_dump($e);
     }
 }
 function get_list_ledger()
 {
     $sql = "select od_id,od_name,od_description from op_predef " . " where jrn_def_id=" . $this->p_jrn . " and od_direct ='" . $this->od_direct . "'" . " order by od_name";
     $res = $this->db->exec_sql($sql);
     $all = Database::fetch_all($res);
     return $all;
 }
Example #13
0
 /**
 * \brief get all the available ledgers for the current user
 * \param $p_type = ALL or the type of the ledger (ACH,VEN,FIN,ODS)
 * \param $p_access =3 for Read or WRITE, 2  write, 1 for readonly
 *  \return a double array of available ledgers
  @verbatim
  [0] => [jrn_def_id]
  [jrn_def_type]
  [jrn_def_name]
  [jrn_def_class_deb]
  [jrn_def_class_cred]
  [jrn_type_id]
  [jrn_desc]
  [uj_priv]
  @endverbatim
 */
 function get_ledger($p_type = 'ALL', $p_access = 3)
 {
     if ($this->admin != 1 && $this->is_local_admin() != 1) {
         $sql_type = $p_type == 'ALL' ? '' : "and jrn_def_type=upper('" . sql_string($p_type) . "')";
         switch ($p_access) {
             case 3:
                 $sql_access = " and uj_priv!= 'X'";
                 break;
             case 2:
                 $sql_access = " and uj_priv = 'W'";
                 break;
             case 1:
                 $sql_access = " and ( uj_priv = 'R' or uj_priv='W') ";
                 break;
         }
         $sql = "select jrn_def_id,jrn_def_type,\n                 jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,\n                 jrn_deb_max_line,jrn_cred_max_line,jrn_def_description\n                 from jrn_def join jrn_type on jrn_def_type=jrn_type_id\n                 join user_sec_jrn on uj_jrn_id=jrn_def_id\n                 where\n                 uj_login='******'" . $sql_type . $sql_access . " order by jrn_Def_id";
     } else {
         $sql_type = $p_type == 'ALL' ? '' : "where jrn_def_type=upper('" . sql_string($p_type) . "')";
         $sql = "select jrn_def_id,jrn_def_type,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,\n                 jrn_type_id,jrn_desc,'W' as uj_priv,jrn_def_description\n                 from jrn_def join jrn_type on jrn_def_type=jrn_type_id\n                 {$sql_type}\n                 order by jrn_Def_name";
     }
     $res = $this->db->exec_sql($sql);
     if (Database::num_row($res) == 0) {
         return null;
     }
     $array = Database::fetch_all($res);
     return $array;
 }
 function load()
 {
     $sql = " select  qs_id,\n             qs_internal,\n             qs_fiche,\n             qs_quantite,\n             qs_price,\n             qs_vat,\n             qs_vat_code,\n             qs_client,\n             j_id,\n             qs_vat_sided\n             from quant_sold \n             where qs_id=\$1";
     $ret = $this->db->exec_sql($sql, array($this->qs_id));
     // $res contains all the line
     $res = Database::fetch_all($ret);
     if (empty($res)) {
         return null;
     }
     foreach ($res[0] as $idx => $value) {
         $this->{$idx} = $value;
     }
 }
Example #15
0
 /**
  * @brief retrieve all the card for this type of ledger, make them
  * into a string separated by comma
  * @paramnone
  * \return all the card or null is nothing is found
  */
 function get_all_fiche_def()
 {
     $sql = "select jrn_def_fiche_deb as deb,jrn_def_fiche_cred as cred " . " from jrn_def where " . " jrn_def_id = \$1 ";
     $r = $this->db->exec_sql($sql, array($this->id));
     $res = Database::fetch_all($r);
     if (empty($res)) {
         return null;
     }
     $card = "";
     $comma = '';
     foreach ($res as $item) {
         if (strlen(trim($item['deb'])) != 0) {
             $card .= $comma . $item['deb'];
             $comma = ',';
         }
         if (strlen(trim($item['cred'])) != '') {
             $card .= $comma . $item['cred'];
             $comma = ',';
         }
     }
     return $card;
 }
 function load()
 {
     $sql = "select  qp_id,\n             qp_internal,\n             qp_fiche,\n             qp_quantite,\n             qp_price,\n             qp_vat,\n             qp_vat_code,\n             qp_nd_amount,\n             qp_nd_tva,\n             qp_nd_tva_recup,\n             qp_supplier,\n             j_id,\n             qp_dep_priv,\n             qp_vat_sided\n             from quant_purchase\n             where qp_id=" . $this->qp_id;
     $ret = $this->db->exec_sql($sql);
     // $res contains all the line
     $res = Database::fetch_all($ret);
     if (empty($res)) {
         return null;
     }
     foreach ($res[0] as $idx => $value) {
         $this->{$idx} = $value;
     }
 }
Example #17
0
 function belong_ledger($p_jrn, $p_type = "")
 {
     // check if we have a quick_code or a f_id
     if (($this->quick_code == null || $this->quick_code == "") && $this->id == 0) {
         throw new Exception('erreur ni quick_code ni f_id ne sont donnes');
     }
     //retrieve the quick_code
     if ($this->quick_code == "") {
         $this->quick_code = $this->get_quick_code();
     }
     if ($this->quick_code == null) {
         return -1;
     }
     if ($this->id == 0) {
         if ($this->get_by_qcode(null, false) == 1) {
             return -1;
         }
     }
     $get = "";
     if ($p_type == 'deb') {
         $get = 'jrn_def_fiche_deb';
     }
     if ($p_type == 'cred') {
         $get = 'jrn_def_fiche_cred';
     }
     if ($get != "") {
         $Res = $this->cn->exec_sql("select {$get} as fiche from jrn_def where jrn_def_id={$p_jrn}");
     } else {
         // Get all the fiche type (deb and cred)
         $Res = $this->cn->exec_sql(" select jrn_def_fiche_cred as fiche\n                                     from jrn_def where jrn_def_id={$p_jrn}\n                                     union\n                                     select jrn_def_fiche_deb\n                                     from jrn_def where jrn_def_id={$p_jrn}");
     }
     $Max = Database::num_row($Res);
     if ($Max == 0) {
         return -2;
     }
     /* convert the array to a string */
     $list = Database::fetch_all($Res);
     $str_list = "";
     $comma = '';
     foreach ($list as $row) {
         if ($row['fiche'] != '') {
             $str_list .= $comma . $row['fiche'];
             $comma = ',';
         }
     }
     // Normally Max must be == 1
     if ($str_list == "") {
         return -3;
     }
     $sql = "select *\n             from fiche\n             where\n             fd_id in (" . $str_list . ") and f_id= " . $this->id;
     $Res = $this->cn->exec_sql($sql);
     $Max = Database::num_row($Res);
     if ($Max == 0) {
         return 0;
     } else {
         return 1;
     }
 }
Example #18
0
    echo _('Résultat') . " " . $g_succeed;
}
$ret = $cn->prepare('get_operation', $sql_concerned_operation);
?>
    
        <?php 
for ($i = 0; $i < $nb_account_used; $i++) {
    ?>
        <h3>
            <?php 
    echo _('Poste comptable ') . $a_account_used[$i]['j_poste'] . _(' pour la fiche ') . $a_account_used[$i]['quick_code'] . " " . $a_account_used[$i]['vw_name'];
    ?>
        </h3>
        <?php 
    $ret_operation = $cn->execute('get_operation', array($a_account_used[$i]['f_id']));
    $a_operation = Database::fetch_all($ret_operation);
    $nb_operation = count($a_operation);
    ?>
        <table class="result">
            <?php 
    for ($x = 0; $x < $nb_operation; $x++) {
        ?>
        <tr>
            <td>
                <?php 
        echo $a_operation[$x]['j_date'];
        ?>
            </td>
            <td>
                <?php 
        echo h($a_operation[$x]['jr_comment']);
Example #19
0
 function get_list()
 {
     $sql = "select fr_id,fr_label from formdef order by fr_label";
     $ret = $this->db->exec_sql($sql);
     if (Database::num_row($ret) == 0) {
         return array();
     }
     $array = Database::fetch_all($ret);
     $obj = array();
     foreach ($array as $row) {
         $tmp = new Acc_Report($this->db);
         $tmp->id = $row['fr_id'];
         $tmp->name = $row['fr_label'];
         $obj[] = clone $tmp;
     }
     return $obj;
 }
 function load()
 {
     $filter_poste = "";
     $and = "";
     if ($this->from_poste != "") {
         $filter_poste .= " {$and} upper(pa.po_name)>= upper('" . Database::escape_string($this->from_poste) . "')";
         $and = " and ";
     }
     if ($this->to_poste != "") {
         $filter_poste .= " {$and} upper(pa.po_name)<= upper('" . Database::escape_string($this->to_poste) . "')";
         $and = " and ";
     }
     if ($this->from_poste2 != "") {
         $filter_poste .= " {$and} upper(pb.po_name)>= upper('" . Database::escape_string($this->from_poste2) . "')";
         $and = " and ";
     }
     if ($this->to_poste2 != "") {
         $filter_poste .= " {$and} upper(pb.po_name)<= upper('" . Database::escape_string($this->to_poste2) . "')";
         $and = " and ";
     }
     if ($filter_poste != "") {
         $filter_poste = " where " . $filter_poste;
     }
     $sql = "\n             select  a_po_id ,\n             pa.po_name as a_po_name,\n             pa.po_description as a_po_description,\n             pb.po_description as b_po_description,\n\n             b_po_id,\n             pb.po_name as b_po_name,\n             sum(a_oa_amount_c) as a_c,\n             sum(a_oa_amount_d) as a_d\n             from (select\n\t\t\ta.j_id,\n             a.po_id as a_po_id,\n             b.po_id as b_po_id,\n             case when a.oa_debit='t' then a.oa_amount else 0 end as a_oa_amount_d,\n             case when a.oa_debit='f' then a.oa_amount else 0 end as a_oa_amount_c\n             from\n             operation_analytique as a join operation_analytique as b on (a.j_id=b.j_id and a.oa_row=b.oa_row)\n\t\tjoin poste_analytique as poa on (a.po_id=poa.po_id)\n\t\tjoin poste_analytique as pob on (b.po_id=pob.po_id)\n             where poa.pa_id=" . $this->pa_id . "\n             and pob.pa_id=" . $this->pa_id2 . "  " . $this->set_sql_filter() . "\n             ) as m join poste_analytique as pa on ( a_po_id=pa.po_id)\n             join poste_analytique as pb on (b_po_id=pb.po_id)\n\n             {$filter_poste}\n\n             group by a_po_id,b_po_id,pa.po_name,pa.po_description,pb.po_name,pb.po_description\n             order by 2;\n             ";
     $res = $this->db->exec_sql($sql);
     $this->has_data = Database::num_row($res);
     if (Database::num_row($res) == 0) {
         return null;
     }
     $a = array();
     $count = 0;
     $array = Database::fetch_all($res);
     foreach ($array as $row) {
         $a[$count]['a_po_id'] = $row['a_po_id'];
         $a[$count]['a_d'] = $row['a_d'];
         $a[$count]['a_c'] = $row['a_c'];
         $a[$count]['b_po_id'] = $row['b_po_id'];
         $a[$count]['a_po_name'] = $row['a_po_name'];
         $a[$count]['a_po_description'] = $row['a_po_description'];
         $a[$count]['b_po_name'] = $row['b_po_name'];
         $a[$count]['b_po_description'] = $row['b_po_description'];
         $a[$count]['a_solde'] = abs($row['a_d'] - $row['a_c']);
         $a[$count]['a_debit'] = $row['a_d'] > $row['a_c'] ? "debit" : "credit";
         $count++;
     }
     return $a;
 }
 function load_all()
 {
     if (!isset($this->jr_id)) {
         echo "jr_id is not set " . __FILE__ . __LINE__;
         throw new Exception('Error : jr_id not set');
     }
     $sql = "select ji_id from jrn_info where jr_id=" . $this->jr_id;
     $r = $this->cn->exec_sql($sql);
     if (Database::num_row($r) == 0) {
         return array();
     }
     $array = Database::fetch_all($r);
     $ret = array();
     foreach ($array as $row) {
         $o = new Acc_Ledger_Info($this->cn, $row['ji_id']);
         $o->load();
         $ret[] = clone $o;
     }
     return $ret;
 }
Example #22
0
 public function load_all()
 {
     $sql = "select tl_id, \n                tl_title,\n                tl_desc,\n                to_char( tl_date,'DD.MM.YYYY') as tl_date,\n                is_public,\n                use_login\n             from todo_list \n             where \n                use_login=\$1\n                or is_public = 'Y'\n                or tl_id in (select todo_list_id from todo_list_shared where use_login=\$1)\n             order by tl_date::date desc";
     $res = $this->cn->exec_sql($sql, array($this->use_login));
     $array = Database::fetch_all($res);
     return $array;
 }
Example #23
0
 /**
  * Show the result of a search in an inner windows, the result is limited to 25
  * @param type $cn database connx
  * @param type $p_sql the query
  */
 static function short_list($cn, $p_sql)
 {
     $sql = "\n             select ag_id,to_char(ag_timestamp,'DD.MM.YY') as my_date,\n\t\t\t f_id_dest,\n             substr(ag_title,1,40) as sub_ag_title,dt_value,ag_ref, ag_priority,ag_state,\n\t\t\tcoalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest,\n\t\t\t\t(select ad_value from fiche_Detail where f_id=action_gestion.f_id_dest and ad_id=1) as name\n             from action_gestion\n             join document_type on (ag_type=dt_id)\n\t\t\t join document_state on (s_id=ag_state)\n             where {$p_sql}";
     $max_line = $cn->count_sql($sql);
     $limit = $max_line > 25 ? 25 : $max_line;
     $Res = $cn->exec_sql($sql . "limit " . $limit);
     $a_row = Database::fetch_all($Res);
     require_once NOALYSS_INCLUDE . '/template/action_search_result.php';
 }
Example #24
0
 function load()
 {
     $ret = $this->db->exec_sql("select pcm_lib,pcm_val_parent,pcm_type from\n                                 tmp_pcmn where pcm_val=\$1", array($this->pcm_val));
     $r = Database::fetch_all($ret);
     if (!$r) {
         return false;
     }
     $this->pcm_lib = $r[0]['pcm_lib'];
     $this->pcm_val_parent = $r[0]['pcm_val_parent'];
     $this->pcm_type = $r[0]['pcm_type'];
     return true;
 }
Example #25
0
//-----------------------------------------------------
// Display
$sql = "select tva_id,tva_label,tva_rate,tva_comment,tva_poste,tva_both_side from tva_rate order by tva_label";
$Res = $cn->exec_sql($sql);
?>
<TABLE>
    <TR>
        <th>Id</th>
	<th>Label</TH>
	<th>Taux</th>
	<th>Commentaire</th>
	<th>Poste</th>
	<th>Utilisé en même temps au crédit et au débit</th>
    </tr>
<?php 
$val = Database::fetch_all($Res);
foreach ($val as $row) {
    // load value into an array
    $index = $row['tva_id'];
    $tva_array[$index] = array('tva_label' => $row['tva_label'], 'tva_rate' => $row['tva_rate'], 'tva_comment' => $row['tva_comment'], 'tva_poste' => $row['tva_poste'], 'tva_both_side' => $row['tva_both_side']);
    echo "<TR>";
    echo '<FORM METHOD="POST">';
    echo '<td>';
    echo $row['tva_id'];
    echo '</td>';
    echo "<TD>";
    echo HtmlInput::hidden('tva_id', $row['tva_id']);
    echo h($row['tva_label']);
    echo "</TD>";
    echo "<TD>";
    echo $row['tva_rate'];
Example #26
0
        $activity = new Activity($httpParam, $_config, $db);
        //TODO
        // add paging to _options
        $_config->options()["start"] = 0;
        $_config->options()["limit"] = 100;
        if ($httpParam->id()) {
            $_config->set("id", $httpParam->id(), "options");
        }
        if ($httpParam->order()) {
            $_config->set("order", $httpParam->order(), "options");
        }
        if ($httpParam->ordertype()) {
            $_config->set("ordertype", $httpParam->ordertype(), "options");
        }
        $db->query($_config->query(), $_config->options());
        $xmlString = $db->fetch_all();
    }
} else {
    // execute activities without database
    $activity = new Activity($httpParam, $_config);
    $xmlString = $_config->html();
}
// =====================================
// transform data for display
$xml = new Xml($xmlString);
// add parameters for xslt transformation
# page data
$page_obj->add("script", $_SERVER["SCRIPT_NAME"]);
$page_obj->add("lang", $lang);
$page_obj->add("order", $order);
$page_obj->add("ordertype", $ordertype);
Example #27
0
 function get_list()
 {
     $sql = "select po_id,\n             po_name ,\n             pa_id,\n             po_amount,\n             po_description,\n             ga_id\n             from poste_analytique " . "   order by po_name";
     $ex = $this->db->exec_sql($sql);
     $ret = Database::fetch_all($ex);
     if ($ret == null) {
         return null;
     }
     $array = array();
     foreach ($ret as $line) {
         $object = new Anc_Account($this->db);
         $object->id = $line['po_id'];
         $object->name = $line['po_name'];
         $object->pa_id = $line['pa_id'];
         $object->amount = $line['po_amount'];
         $object->description = $line['po_description'];
         $object->ga_id = $line['ga_id'];
         $array[] = clone $object;
     }
     return $array;
 }