Author: danydb Date: 2014-01-09 16:41:44 +0100 (Thu, 09 Jan 2014) New Revision: 655
Removed: trunk/invoicing/include/class_skel_parameter.php Modified: trunk/invoicing/include/class_acc_ledger_sold_generate.php trunk/invoicing/include/invoice_generate.inc.php Log: Add generate invoice Modified: trunk/invoicing/include/class_acc_ledger_sold_generate.php =================================================================== --- trunk/invoicing/include/class_acc_ledger_sold_generate.php 2014-01-09 15:41:27 UTC (rev 654) +++ trunk/invoicing/include/class_acc_ledger_sold_generate.php 2014-01-09 15:41:44 UTC (rev 655) @@ -19,7 +19,7 @@ */ // Copyright Author Dany De Bontridder [email protected] - +require_once 'class_acc_ledger_sold.php'; class Acc_Ledger_Sold_Generate extends Acc_Ledger_Sold { @@ -285,5 +285,73 @@ return array($count, $r); } - + /** + * @brief + */ + function convert_to_array(Acc_Sold $sold) + { + $item=count($sold->det->array); + if ( $item ==0) + { + throw new Exception('No Data in Quant_Purchase'); + } + $array=array(); + + $array['e_ech']=$sold->det->jrn_ech; + $array['e_comm']=$sold->det->jr_comment; + $array['p_jrn']=$sold->det->jr_def_id; + $array['nb_item']=$item; + $array['ledger_type']=$sold->signature; + $array['e_date']= format_date($sold->det->jr_date); + $array['e_pj']= $sold->det->jr_pj_number; + + $this->pj=$array['e_pj']; + $array['internal']=$sold->det->jr_internal; + + $client=new Fiche($sold->db,$sold->det->array[0]['qs_client']); + $array['e_client']=$client->get_quick_code(); + bcscale(2); + for ($i=0;$i < $item ; $i++) + { + $idx='e_march'; + $serv=new Fiche($sold->db,$sold->det->array[$i]['qs_fiche']); + $array[$idx.$i]=$serv->get_quick_code(); + $array[$idx.$i.'_label']=$sold->det->array[$i]['j_text']; + $array[$idx.$i.'_price']=bcdiv($sold->det->array[$i]['qs_price'],$sold->det->array[$i]['qs_quantite']); + $array[$idx.$i.'_tva_id']=$sold->det->array[$i]['qs_vat_code']; + $array[$idx.$i.'_tva_amount']=$sold->det->array[$i]['qs_vat']; + $array['e_quant'.$i]=$sold->det->array[$i]['qs_quantite']; + } + return $array; + + + } + /** + * + * @param type $p_array + * @param type $p_doc + * @return type + */ + function create_document($p_array,$p_doc) + { + $internal=$p_array['internal']; + $p_array['gen_doc']=$p_doc; + return parent::create_document($internal,$p_array); + } + static function test_me($p_string = '') + { + $_SESSION['g_user']='phpcompta'; + $_SESSION['g_pass']='phpcompta'; + global $g_user; + $cn=new Database(dossier::id()); + $g_user=new User($cn); + $a=new Acc_Operation($cn); + $a->jr_id=2889; + $b=$a->get_quant(); + var_dump($b); + $c=new Acc_Ledger_Sold_Generate($cn,$b->det->jr_def_id); + $array=$c->convert_to_array($b); + var_dump($array); + echo $c->create_document($array, 8); + } } Deleted: trunk/invoicing/include/class_skel_parameter.php =================================================================== --- trunk/invoicing/include/class_skel_parameter.php 2014-01-09 15:41:27 UTC (rev 654) +++ trunk/invoicing/include/class_skel_parameter.php 2014-01-09 15:41:44 UTC (rev 655) @@ -1,75 +0,0 @@ -<?php - -/* - * This file is part of PhpCompta. - * - * PhpCompta is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * PhpCompta is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with PhpCompta; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -/* $Revision$ */ - -// Copyright Author Dany De Bontridder [email protected] - -/** - * @file - * @brief class for the table SKEL.parameter - * replace SKEL by the plugin schema - * - */ -class SKEL_Parameter -{ - // constructor - function __construct() { - $this->db=$p_cn; - $Res=$p_cn->exec_sql("select * from SKEL.parameter "); - for ($i = 0;$i < Database::num_row($Res);$i++) - { - $row=Database::fetch_array($Res,$i); - $key=$row['pr_id']; - $elt=$row['pr_value']; - - // store value here - $this->{"$key"}=$elt; - } - - } - /*! - ************************************************** - * \brief save the parameter into the database by inserting or updating - * - * - * \param $p_attr give the attribut name - * - */ - function save($p_option,$p_value) - { - global $cn; - // check if the parameter does exist - if ( $this->cn->get_value('select count(*) from SKEL.parameter where pr_id=$1',array($p_option)) != 0 ) - { - $Res=$this->cn->exec_sql("update SKEL.parameter set pr_value=$1 where pr_id=$2", - array($p_value,$p_option)); - } - else - { - - $Res=$this->cn->exec_sql("insert into SKEL.parameter (pr_id,pr_value) values( $1,$2)", - array($p_option,$p_value)); - - } - - } - -} -?> Modified: trunk/invoicing/include/invoice_generate.inc.php =================================================================== --- trunk/invoicing/include/invoice_generate.inc.php 2014-01-09 15:41:27 UTC (rev 654) +++ trunk/invoicing/include/invoice_generate.inc.php 2014-01-09 15:41:44 UTC (rev 655) @@ -1,5 +1,4 @@ <?php - /* * This file is part of PhpCompta. * @@ -21,8 +20,47 @@ /** * @file - * @brief regenerate all the invoice + * @brief regenerate all the invoices of the selected operations * @param type $name Descriptionara + * @code + * + 'sel_sale' => + array + 0 => string '2832' (length=4) + 1 => string '2871' (length=4) + 2 => string '2889' (length=4) + 3 => string '2939' (length=4) + 'action' => string '2' (length=1) + 'document' => string '8' (length=1) + * @endcode */ -var_dump($_REQUEST); +require_once 'class_acc_ledger_sold_generate.php'; +//--- take all the invoices ?> +<h1> Génération de factures</h1> +<ol> + + <?php + foreach ($_GET['sel_sale'] as $key => $value) + { + $operation = new Acc_Operation($cn); + $operation->jr_id = $value; + $op_sale = $operation->get_quant(); + $generate = new Acc_Ledger_Sold_Generate($cn, $op_sale->det->jr_def_id); + $array = $generate->convert_to_array($op_sale); + ?> + <li> + <?php echo $generate->create_document($array, $_GET['document']); ?> + </li> + <?php + } + ?> +</ol> +<form method="get"> + <?php + echo HtmlInput::get_to_hidden(array('gDossier', 'ac', 'plugin_code', 'sel_sale')); + echo HtmlInput::hidden('action','1'); + ?> + + <?php echo HtmlInput::submit('tl',_('Télécharger toutes les factures')); ?> +</form> --- PhpCompta est un logiciel de comptabilité libre en ligne (full web) Projet opensource http://www.phpcompta.eu _______________________________________________ Phpcompta est un logiciel libre de comptabilité en ligne (http://www.phpcompta.eu) Phpcompta-dev mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/phpcompta-dev
