phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r646 - in trunk: . invoicing invoicing/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r646 - in trunk: . invoicing invoicing/include
Date: Sun, 5 Jan 2014 22:28:43 +0100 (CET)

Author: danydb
Date: 2014-01-05 22:28:43 +0100 (Sun, 05 Jan 2014)
New Revision: 646

Added:
   trunk/invoicing/
   trunk/invoicing/README.txt
   trunk/invoicing/ajax.php
   trunk/invoicing/doc/
   trunk/invoicing/include/
   trunk/invoicing/include/class_acc_ledger_sold_generate.php
   trunk/invoicing/include/class_install_plugin.php
   trunk/invoicing/include/class_skel_parameter.php
   trunk/invoicing/include/invoice_generate.inc.php
   trunk/invoicing/include/invoice_send_mail.inc.php
   trunk/invoicing/include/invoice_to_zip.inc.php
   trunk/invoicing/include/invoicing.inc.php
   trunk/invoicing/include/template/
   trunk/invoicing/index.php
   trunk/invoicing/invoicing_constant.php
   trunk/invoicing/invoicing_javascript.js
   trunk/invoicing/raw.php
Log:
Invoicing : new plugin, download all invoices

Added: trunk/invoicing/README.txt
===================================================================
--- trunk/invoicing/README.txt                          (rev 0)
+++ trunk/invoicing/README.txt  2014-01-05 21:28:43 UTC (rev 646)
@@ -0,0 +1,5 @@
+--- Facturation ---
+1. Télécharger les factures en un seul fichier compressé
+2. Régénérer les factures
+3. Envoi des factures avec conversion PDF
+

Added: trunk/invoicing/ajax.php
===================================================================
--- trunk/invoicing/ajax.php                            (rev 0)
+++ trunk/invoicing/ajax.php    2014-01-05 21:28:43 UTC (rev 646)
@@ -0,0 +1,33 @@
+<?php
+require_once('skel_constant.php');
+require_once('class_database.php');
+require_once('class_ext_tva.php');
+require_once('class_ibutton.php');
+require_once ('class_ext_list_intra.php');
+require_once ('class_ext_list_assujetti.php');
+
+extract($_GET);
+global $cn;
+$html='';$extra='';$ctl='';
+ob_start();
+switch($act) {
+case 'dsp_decl':
+  /* the hide button */
+  require_once('include/ajax_dsp.php');
+  break;
+}
+
+$html=ob_get_contents();
+
+ob_end_clean();
+
+$html=escape_xml($html);
+
+header('Content-type: text/xml; charset=UTF-8');
+echo '<?xml version="1.0" encoding="UTF-8"?>';
+echo '<data>';
+echo "<ctl>$ctl</ctl>";
+echo "<html>$html</html>";
+echo "<extra>$extra</extra>";
+echo "</data>";
+?>

Added: trunk/invoicing/include/class_acc_ledger_sold_generate.php
===================================================================
--- trunk/invoicing/include/class_acc_ledger_sold_generate.php                  
        (rev 0)
+++ trunk/invoicing/include/class_acc_ledger_sold_generate.php  2014-01-05 
21:28:43 UTC (rev 646)
@@ -0,0 +1,289 @@
+<?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
+ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+class Acc_Ledger_Sold_Generate extends Acc_Ledger_Sold
+{
+
+    /**
+     * @brief Show all the operation of ledger Sold 
+     * @param$sql is the sql stmt, normally created by build_search_sql
+     * @param$offset the offset
+     * @param$p_paid if we want to see info about payment
+      \code
+      // Example
+      // Build the sql
+      list($sql,$where)=$Ledger->build_search_sql($_GET);
+      // Count nb of line
+      $max_line=$cn->count_sql($sql);
+
+      $step=$_SESSION['g_pagesize'];
+      $page=(isset($_GET['offset']))?$_GET['page']:1;
+      $offset=(isset($_GET['offset']))?$_GET['offset']:0;
+      // create the nav. bar
+      $bar=navigation_bar($offset,$max_line,$step,$page);
+      // show a part
+      list($count,$html)= $Ledger->list_operation($sql,$offset,0);
+      echo $html;
+      // show nav bar
+      echo $bar;
+
+      \endcode
+     * \see build_search_sql
+     * \see display_search_form
+     * \see search_form
+
+     * \return HTML string
+     */
+    public function list_operation($sql, $offset, $p_paid = 0)
+    {
+        global $g_parameter, $g_user;
+        bcscale(2);
+        $table = new Sort_Table();
+        $gDossier = dossier::id();
+        $amount_paid = 0.0;
+        $amount_unpaid = 0.0;
+        $limit = ($_SESSION['g_pagesize'] != -1) ? " LIMIT " . 
$_SESSION['g_pagesize'] : "";
+        $offset = ($_SESSION['g_pagesize'] != -1) ? " OFFSET " . 
Database::escape_string($offset) : "";
+        $order = "  order by jr_date_order asc,jr_internal asc";
+        // Sort
+        $url = "?" . CleanUrl();
+        $str_dossier = dossier::get();
+        $table->add("Date", $url, 'order by jr_date 
asc,substring(jr_pj_number,\'[0-9]+$\')::numeric asc', 'order by  jr_date 
desc,substring(jr_pj_number,\'[0-9]+$\')::numeric desc', "da", "dd");
+        $table->add('Echeance', $url, " order by  jr_ech asc", " order by  
jr_ech desc", 'ea', 'ed');
+        $table->add('Paiement', $url, " order by  jr_date_paid asc", " order 
by  jr_date_paid desc", 'eap', 'edp');
+        $table->add('PJ', $url, ' order by  
substring(jr_pj_number,\'[0-9]+$\')::numeric asc ', ' order by  
substring(jr_pj_number,\'[0-9]+$\')::numeric desc ', "pja", "pjd");
+        $table->add('Tiers', $url, " order by  name asc", " order by  name 
desc", 'na', 'nd');
+        $table->add('Montant', $url, " order by jr_montant asc", " order by 
jr_montant desc", "ma", "md");
+        $table->add("Description", $url, "order by jr_comment asc", "order by 
jr_comment desc", "ca", "cd");
+
+        $ord = (!isset($_GET['ord'])) ? 'da' : $_GET['ord'];
+        $order = $table->get_sql_order($ord);
+
+        // Count
+        $count = $this->db->count_sql($sql);
+        // Add the limit
+        $sql.=$order . $limit . $offset;
+        // Execute SQL stmt
+        $Res = $this->db->exec_sql($sql);
+
+        //starting from here we can refactor, so that instead of returning the 
generated HTML,
+        //this function returns a tree structure.
+
+        $r = "";
+
+
+        $Max = Database::num_row($Res);
+
+        if ($Max == 0)
+            return array(0, _("Aucun enregistrement trouvé"));
+
+        $r.='<table class="result">';
+
+
+        $r.="<tr >";
+        $r.='<th>';
+        $r.=ICheckbox::toggle_checkbox('sellall',"sel_sale_frm");
+        $r.='</th>';
+        $r.="<th>Internal</th>";
+        if ($this->type == 'ALL')
+        {
+            $r.=th('Journal');
+        }
+        $r.='<th>' . $table->get_header(0) . '</th>';
+        $r.='<th>' . $table->get_header(1) . '</td>';
+        $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(6) . '</th>';
+        $r.=th('Notes', ' style="width:15%"');
+        $r.='<th>' . $table->get_header(5) . '</th>';
+        // if $p_paid is not equal to 0 then we have a paid column
+        if ($p_paid != 0)
+        {
+            $r.="<th> " . _('Payé') . "</th>";
+        }
+        $r.="<th>" . _('Concerne') . "</th>";
+        $r.="<th>" . _('Document') . "</th>";
+        $r.="</tr>";
+        // Total Amount
+        $tot = 0.0;
+        $gDossier = dossier::id();
+        for ($i = 0; $i < $Max; $i++)
+        {
+
+
+            $row = Database::fetch_array($Res, $i);
+
+            if ($i % 2 == 0)
+                $tr = '<TR class="odd">';
+            else
+                $tr = '<TR class="even">';
+            $r.=$tr;
+            $checkbox=new ICheckBox('sel_sale[]');
+            $checkbox->value=$row['jr_id'];
+            $r.=td($checkbox->input());
+            //internal code
+            // button  modify
+            $r.="<TD>";
+            // If url contains
+            //
+
+            $href = basename($_SERVER['PHP_SELF']);
+
+
+            $r.=sprintf('<A class="detail" style="text-decoration:underline" 
HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s </A>', $row['jr_id'], 
$gDossier, $row['jr_internal']);
+            $r.="</TD>";
+            if ($this->type == 'ALL')
+                $r.=td($row['jrn_def_name']);
+            // date
+            $r.="<TD>";
+            $r.=$row['str_jr_date'];
+            $r.="</TD>";
+            // echeance
+            $r.="<TD>";
+            $r.=$row['str_jr_ech'];
+            $r.="</TD>";
+            $r.="<TD>";
+            $r.=$row['str_jr_date_paid'];
+            $r.="</TD>";
+
+            // pj
+            $r.="<TD>";
+            $r.=$row['jr_pj_number'];
+            $r.="</TD>";
+
+            // Tiers
+            $other = ($row['quick_code'] != '') ? '[' . $row['quick_code'] . 
'] ' . $row['name'] . ' ' . $row['first_name'] : '';
+            $r.=td($other);
+            // comment
+            $r.="<TD>";
+            $tmp_jr_comment = h($row['jr_comment']);
+            $r.=$tmp_jr_comment;
+            $r.="</TD>";
+            $r.=td(h($row['n_text']), ' style="font-size:0.87em%"');
+            // Amount
+            // If the ledger is financial :
+            // the credit must be negative and written in red
+            $positive = 0;
+
+            // Check ledger type :
+            if ($row['jrn_def_type'] == 'FIN')
+            {
+                $positive = $this->db->get_value("select qf_amount from 
quant_fin where jr_id=$1", array($row['jr_id']));
+                if ($this->db->count() != 0)
+                    $positive = ($positive < 0) ? 1 : 0;
+            }
+            $r.="<TD align=\"right\">";
+            $t_amount = $row['jr_montant'];
+            if ($row['total_invoice'] != null && $row['total_invoice'] != 
$row['jr_montant'])
+                $t_amount = $row['total_invoice'];
+            $tot = ($positive != 0) ? bcsub($tot, $t_amount) : bcadd($tot, 
$t_amount);
+            //STAN $positive always == 0
+            if ($row ['jrn_def_type'] == 'FIN')
+            {
+                $r.=( $positive != 0 ) ? "<font color=\"red\">  - " . 
nbm($t_amount) . "</font>" : nbm($t_amount);
+            } else
+            {
+                $r.=( $t_amount < 0 ) ? "<font color=\"red\">  " . 
nbm($t_amount) . "</font>" : nbm($t_amount);
+            }
+            $r.="</TD>";
+
+
+            // Show the paid column if p_paid is not null
+            if ($p_paid != 0)
+            {
+                $w = new ICheckBox();
+                $w->name = "rd_paid" . $row['jr_id'];
+                $w->selected = ($row['jr_rapt'] == 'paid') ? true : false;
+                // if p_paid == 2 then readonly
+                $w->readonly = ( $p_paid == 2) ? true : false;
+                $h = new IHidden();
+                $h->name = "set_jr_id" . $row['jr_id'];
+                $r.='<TD>' . $w->input() . $h->input() . '</TD>';
+                if ($row['jr_rapt'] == 'paid')
+                    $amount_paid = bcadd($amount_paid, $t_amount);
+                else
+                    $amount_unpaid = bcadd($amount_unpaid, $t_amount);
+            }
+
+            // Rapprochement
+            $rec = new Acc_Reconciliation($this->db);
+            $rec->set_jr_id($row['jr_id']);
+            $a = $rec->get();
+            $r.="<TD>";
+            if ($a != null)
+            {
+
+                foreach ($a as $key => $element)
+                {
+                    $operation = new Acc_Operation($this->db);
+                    $operation->jr_id = $element;
+                    $l_amount = $this->db->get_value("select jr_montant from 
jrn " .
+                            " where jr_id=$element");
+                    $r.= "<A class=\"detail\" 
HREF=\"javascript:modifyOperation('" . $element . "'," . $gDossier . ")\" > " . 
$operation->get_internal() . "[" . nbm($l_amount) . "]</A>";
+                }//for
+            }// if ( $a != null ) {
+            $r.="</TD>";
+
+            if ($row['jr_valid'] == 'f')
+            {
+                $r.="<TD> Op&eacute;ration annul&eacute;e</TD>";
+            } else
+            {
+                
+            } // else
+            //document
+            if ($row['jr_pj_name'] != "")
+            {
+                $image = '<IMG SRC="image/insert_table.gif" title="' . 
$row['jr_pj_name'] . '" border="0">';
+                $r.="<TD>" . sprintf('<A class="detail" 
HREF="show_pj.php?jrn=%s&jr_grpt_id=%s&%s">%s</A>', $row['jrn_def_id'], 
$row['jr_grpt_id'], $str_dossier, $image)
+                        . "</TD>";
+            } else
+                $r.="<TD></TD>";
+
+            // end row
+            $r.="</tr>";
+        }
+        $amount_paid = round($amount_paid, 4);
+        $amount_unpaid = round($amount_unpaid, 4);
+        $tot = round($tot, 4);
+        $r.="<TR>";
+        $r.='<TD COLSPAN="5">Total</TD>';
+        $r.='<TD ALIGN="RIGHT">' . nbm($tot) . "</TD>";
+        $r.="</tr>";
+        if ($p_paid != 0)
+        {
+            $r.="<TR>";
+            $r.='<TD COLSPAN="5">Pay&eacute;</TD>';
+            $r.='<TD ALIGN="RIGHT">' . nbm($amount_paid) . "</TD>";
+            $r.="</tr>";
+            $r.="<TR>";
+            $r.='<TD COLSPAN="5">Non pay&eacute;</TD>';
+            $r.='<TD ALIGN="RIGHT">' . nbm($amount_unpaid) . "</TD>";
+            $r.="</tr>";
+        }
+        $r.="</table>";
+
+        return array($count, $r);
+    }
+
+}

Added: trunk/invoicing/include/class_install_plugin.php
===================================================================
--- trunk/invoicing/include/class_install_plugin.php                            
(rev 0)
+++ trunk/invoicing/include/class_install_plugin.php    2014-01-05 21:28:43 UTC 
(rev 646)
@@ -0,0 +1,83 @@
+<?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 address@hidden
+
+/**\file
+ * \brief this class manages the installation and the patch of the plugin
+ replace SKEL by the plugin schema
+ */
+
+class Install_Plugin
+{
+
+       function __construct($p_cn)
+       {
+               $this->cn = $p_cn;
+       }
+
+       /**
+        * @brief install the plugin, create all the needed schema, tables, proc
+        * in the database
+        * @param $p_dossier is the dossier id
+        */
+       function install()
+       {
+               $this->cn->start();
+               // create the schema
+               $this->create_schema();
+               // create table + put default values
+               $this->create_table_parameter();
+               $this->cn->commit();
+       }
+
+       function create_schema()
+       {
+               $this->cn->exec_sql('create schema SKEL');
+       }
+
+       function create_table_parameter()
+       {
+               $sql = <<<EOF
+CREATE TABLE SKEL.parameter
+(
+  pr_id text NOT NULL,
+  pr_value text,
+  CONSTRAINT SKEL_parameter_pkey PRIMARY KEY (pr_id)
+ );
+EOF;
+               $this->cn->exec_sql($sql);
+// load default value
+               $array = array(
+                       'GRIL00' => array('6'),
+                       'GRIL01' => array('3'),
+                       'GRIL02' => array('2', ''),
+
+               );
+
+               foreach ($array as $code => $value)
+               {
+                       $this->cn->exec_sql('insert into 
SKEL.parameter(pr_id,pr_value,pr_other) values ($1,$2)', array($code, 
$value[0]));
+               }
+       }
+
+}
+

Added: trunk/invoicing/include/class_skel_parameter.php
===================================================================
--- trunk/invoicing/include/class_skel_parameter.php                            
(rev 0)
+++ trunk/invoicing/include/class_skel_parameter.php    2014-01-05 21:28:43 UTC 
(rev 646)
@@ -0,0 +1,75 @@
+<?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 address@hidden
+
+/**
+ * @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));
+
+        }
+
+    }
+
+}
+?>

Added: trunk/invoicing/include/invoice_generate.inc.php
===================================================================
--- trunk/invoicing/include/invoice_generate.inc.php                            
(rev 0)
+++ trunk/invoicing/include/invoice_generate.inc.php    2014-01-05 21:28:43 UTC 
(rev 646)
@@ -0,0 +1,27 @@
+<?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
+ */
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief 
+ * @param type $name Descriptionara
+ */
+?>

Added: trunk/invoicing/include/invoice_send_mail.inc.php
===================================================================
--- trunk/invoicing/include/invoice_send_mail.inc.php                           
(rev 0)
+++ trunk/invoicing/include/invoice_send_mail.inc.php   2014-01-05 21:28:43 UTC 
(rev 646)
@@ -0,0 +1,27 @@
+<?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
+ */
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief 
+ * @param type $name Descriptionara
+ */
+?>

Added: trunk/invoicing/include/invoice_to_zip.inc.php
===================================================================
--- trunk/invoicing/include/invoice_to_zip.inc.php                              
(rev 0)
+++ trunk/invoicing/include/invoice_to_zip.inc.php      2014-01-05 21:28:43 UTC 
(rev 646)
@@ -0,0 +1,76 @@
+<?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
+ */
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief take all the invoices, create a large zip file and propose to 
download
+ * it
+ * @param sel_sale array of choosen jr_id
+ * 
+ */
+//- create a tmp folder 
+$dirname = tempnam($_ENV['TMP'], 'invoice');
+unlink($dirname);
+mkdir($dirname);
+$cn->start();
+$feedback = array();
+//--- take all the invoice
+foreach ($_GET['sel_sale'] as $key => $value)
+{
+    $a_invoice = $cn->get_array("select jr_pj_name,jr_pj from jrn where jr_id 
= $1", array($value));
+    $invoice = $a_invoice[0];
+    if ($invoice['jr_pj_name'] != "" && $invoice['jr_pj'] != "")
+    {
+        $file = $dirname . '/' . $invoice['jr_pj_name'];
+        $cn->lo_export($invoice['jr_pj'], $file);
+        $feedback[] = _('Ajout facture ') . $invoice['jr_pj_name'];
+    }
+}
+// -- zip file
+$date = date('ymd.Hi');
+$zip_file = $_ENV['TMP'] . "/" . "invoice-" . $date . ".zip";
+
+// --- create the zip
+$zip = new Zip_Extended();
+$res = $zip->open($zip_file, ZipArchive::CREATE);
+if ($res != true)
+{
+    var_dump($res);
+    exit();
+}
+$zip->add_recurse_folder($dirname . "/");
+$zip->close();
+//-- send the zip
+$link = http_build_query(array('gDossier' => Dossier::id(), 'ac' => 
$_REQUEST['ac'], 'plugin_code' => $_REQUEST['plugin_code'], 'file' => 
$zip_file));
+?>
+<p>
+<h2>
+    <?php echo _('Facture'); ?>
+</h2>
+<ol>
+    <?php foreach ($feedback as $row): ?>
+
+        <li>
+            <?php echo $row ?>
+        </li>
+    <?php endforeach; ?>
+</ol>
+</p>
+<a class="detail" style="display:inline;text-decoration: underline" 
href="extension.raw.php?<?php echo $link; ?>"> <?php echo _('Télécharger le 
fichier') ?></a>
\ No newline at end of file

Added: trunk/invoicing/include/invoicing.inc.php
===================================================================
--- trunk/invoicing/include/invoicing.inc.php                           (rev 0)
+++ trunk/invoicing/include/invoicing.inc.php   2014-01-05 21:28:43 UTC (rev 
646)
@@ -0,0 +1,129 @@
+<?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
+ */
+// Copyright Author Dany De Bontridder address@hidden
+require_once 'class_acc_ledger_sold_generate.php';
+$ledger = new Acc_Ledger_Sold_Generate($cn, -1);
+$_GET['ledger_type'] = 'VEN';
+//var_dump($_GET);
+$request = HtmlInput::default_value_get('action', -2);
+if ($request <> -2)
+{
+    if (!isset($_GET['sel_sale']))
+    {
+        echo h2("Rien n'a été choisi", 'class="notice"');
+    } else
+    {
+        switch ($request)
+        {
+            case 1:
+                // Download zip
+                require ('invoice_to_zip.inc.php');
+                break;
+            case 2:
+                // regenerer facture
+                require ('invoice_generate.inc.php');
+                break;
+            case 3:
+                // Envoi facture par email
+                require('invoice_send_mail.inc.php');
+                break;
+        }
+        exit();
+    }
+}
+echo $ledger->display_search_form();
+// Example
+// Build the sql
+list($sql, $where) = $ledger->build_search_sql($_GET);
+// Count nb of line
+$max_line = $cn->count_sql($sql);
+
+$offset = 0;
+// show a part
+list($count, $html) = $ledger->list_operation($sql, $offset, 0);
+
+// --- template Invoice  to generate --- //
+$document=new ISelect('document');
+$document->value=$cn->make_array('select md_id,md_name from document_modele 
order by 2');
+
+$document_to_send=new ISelect('format_document');
+$document_to_send->value=array(
+    array('value'=>'1','Convertire en PDF'),
+    array('value'=>'2','Envoi de la facture sans conversion en PDF')
+)
+?>
+<form method="GET" id="sel_sale_frm">
+    Ajouter dans le form les valeurs de la recherches
+    <?php
+    echo HtmlInput::request_to_hidden(array('gDossier', 'ac', 'plugin_code'));
+    echo HtmlInput::request_to_hidden(array('date_start', 'date_end'));
+    echo HtmlInput::request_to_hidden(array('date_paid_start', 
'date_paid_end'));
+    echo HtmlInput::request_to_hidden(array('amount_min', 'amount_max'));
+    echo HtmlInput::request_to_hidden(array('desc', 'qcode', 'accounting'));
+    echo HtmlInput::request_to_hidden(array('r_jrn'));
+    echo $html;
+    ?>
+    <ul style="list-style-type: none">
+        <li>
+            
+            <input type="radio" name="action" value="1" 
+                   
onclick="$('invoice_div').hide();$('send_mail_div').hide();">
+            <?php echo _('Télécharger toutes les factures') ?>
+        </li>
+        <li>
+          
+            <input type="radio" name="action" value="2" 
+                   
onclick="$('invoice_div').show();$('send_mail_div').hide();">
+              <?php echo _('Générer les factures') ?>
+            <div id="invoice_div" style="display:none">
+                <?php echo _('Document à générer'); ?> : <?php echo 
$document->input(); ?>
+            </div>
+        </li>
+        <li>
+            
+            <input type="radio" name="action" value="3" 
+                   
onclick="$('invoice_div').hide();$('send_mail_div').show();">
+            <?php echo _('Envoi des factures par email') ?>
+            <div id="send_mail_div" style="display:none">
+                <h2 class="note"><?php echo _('Envoi uniquement à ceux ayant 
une adresse email et une facture')?> </h2>
+                <p>
+                    <input type="checkbox" name="pdf"> <?php echo 
_('Conversion en PDF'); ?>
+                </p>
+                <p>
+                    <input type="checkbox" name="copy"> <?php echo _('Copie 
envoyée à'); ?>
+                    <input type="text" name="email_copy" class="input_text">
+                </p>
+                <p>
+                    <?php echo _('Sujet')?> : 
+                    <input type="text" name="email_subject" class="input_text">
+                </p>
+                <p>
+                    <?php echo _('Message')?> : 
+                    <textarea style="vertical-align: top;width:23%;height:10%" 
name="message" class="input_text">               </textarea>
+                </p>
+                
+            </div>
+        </li>
+    </ul>   
+    <p>
+        <?php
+        echo HtmlInput::submit('choice_sel', 'Exécuter');
+        ?>
+    </p>
+</form>

Added: trunk/invoicing/index.php
===================================================================
--- trunk/invoicing/index.php                           (rev 0)
+++ trunk/invoicing/index.php   2014-01-05 21:28:43 UTC (rev 646)
@@ -0,0 +1,43 @@
+<?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 address@hidden
+
+/*!\file
+ * \brief main file for tva
+ */
+
+/*
+ * load javascript
+ */
+
+ob_start();
+require_once('invoicing_javascript.js');
+$j=ob_get_contents();
+ob_end_clean();
+echo create_script($j);
+global $version_plugin;
+$version_plugin=SVNINFO;
+Extension::check_version(5500);
+require_once 'class_acc_ledger_sold.php';
+require_once 'include/invoicing.inc.php';
+require_once('class_zip_extended.php');
+
+?>

Added: trunk/invoicing/invoicing_constant.php
===================================================================
--- trunk/invoicing/invoicing_constant.php                              (rev 0)
+++ trunk/invoicing/invoicing_constant.php      2014-01-05 21:28:43 UTC (rev 
646)
@@ -0,0 +1,17 @@
+<?php 
+/**
+ address@hidden
+ *Contains all the needed variable for the plugin
+ *is name is plugin_name_constant.php
+ * You can use some globale variable, especially for the database
+ *  connection
+ */
+
+require_once ('class_database.php');
+
+global $cn,$g_SKEL_parameter;
+$cn=new Database (dossier::id());
+
+// document_type.dt_id, dt_value='FACTURE'
+define ('DOCUMENT_TYPE',4); 
+?>
\ No newline at end of file

Added: trunk/invoicing/invoicing_javascript.js
===================================================================
--- trunk/invoicing/invoicing_javascript.js                             (rev 0)
+++ trunk/invoicing/invoicing_javascript.js     2014-01-05 21:28:43 UTC (rev 
646)
@@ -0,0 +1,142 @@
+/**
+ *javascript
+ */
+function add_material(dossier_id,plugin_code,target)
+{
+    var 
qs="?gDossier="+dossier_id+'&plugin_code='+plugin_code+'&op=add_mat&t='+target;
+    
+    var action=new Ajax.Request ( 'ajax.php',
+                                 {
+                                     method:'get',
+                                     parameters:qs,
+                                     onFailure:error_ajax,
+                                     onSuccess:success_add_material
+                                 }
+                               );
+    if ( $(target)) 
+    {
+       removeDiv(target);
+    }
+
+    var sx=0;
+    if ( window.scrollY)
+    {
+            sx=window.scrollY+120;
+    }
+     else
+     {
+            sx=document.body.scrollTop+120;
+     }
+    var str_style="top:"+sx+";width:50%;height:70%";
+
+    var div={id:target, cssclass:'inner_box',style:str_style,html:loading()};
+    
+    add_div(div);
+
+}
+function display_material(dossier_id,f_id,plugin_code,target)
+{
+    var 
qs="?gDossier="+dossier_id+'&plugin_code='+plugin_code+'&op=display_modify&t='+target+'&f='+f_id;
+    
+    var action=new Ajax.Request ( 'ajax.php',
+                                 {
+                                     method:'get',
+                                     parameters:qs,
+                                     onFailure:error_ajax,
+                                     onSuccess:success_add_material
+                                 }
+                               );
+    if ( $(target)) 
+    {
+       removeDiv(target);
+    }
+
+    var sx=0;
+    if ( window.scrollY)
+    {
+            sx=window.scrollY+120;
+    }
+     else
+     {
+            sx=document.body.scrollTop+120;
+     }
+    var str_style="top:"+sx+";width:50%;height:auto";
+
+    var div={id:target, cssclass:'inner_box',style:str_style,html:loading()};
+    
+    add_div(div);
+
+}
+function success_add_material(req)
+{
+    fill_box(req);
+
+}
+function error_ajax() {
+    alert('Erreur ajax AMORTIS');
+}
+
+/**
+*Answer to a post (or get) in ajax
+*/
+function save_new_material(obj)
+{
+
+    var querystring="?"+$(obj).serialize()+'&op=save_new_material&t=bxmat';
+
+    // Create a ajax request to get all the person
+    var action = new Ajax.Request ('ajax.php',
+                                  {
+                                      method: 'post',
+                                      parameters: querystring,
+                                      onFailure: error_ajax,
+                                      onSuccess: success_save_new_material
+                                  }
+                                  );
+
+    return false;   
+}
+
+function success_save_new_material(req)
+{
+    fill_box(req);
+    $('bxmat').style.height='auto';
+}
+function save_modify(obj)
+{
+     var querystring="?"+$(obj).serialize()+'&op=save_modify&t=bxmat';
+
+    // Create a ajax request to get all the person
+    var action = new Ajax.Request ('ajax.php',
+                                  {
+                                      method: 'post',
+                                      parameters: querystring,
+                                      onFailure: error_ajax,
+                                      onSuccess: success_save_modify
+                                  }
+                                  );
+
+    return false;   
+   
+}
+function success_save_modify(req)
+{
+    fill_box(req);
+
+}
+function remove_mat(g_dossier,plugin_code,a_id)
+{
+    if ( ! confirm('Vous confirmez EFFACEMENT')) { return false;}
+    var 
qs="?gDossier="+g_dossier+"&plugin_code="+plugin_code+"&a_id="+a_id+"&op=rm&t=bxmat";
     
+    var action=new Ajax.Request ( 'ajax.php',
+                                 {
+                                     method:'get',
+                                     parameters:qs,
+                                     onFailure:error_ajax,
+                                     onSuccess:success_add_material
+                                 }
+                               );
+ 
+
+   
+}
\ No newline at end of file

Added: trunk/invoicing/raw.php
===================================================================
--- trunk/invoicing/raw.php                             (rev 0)
+++ trunk/invoicing/raw.php     2014-01-05 21:28:43 UTC (rev 646)
@@ -0,0 +1,42 @@
+<?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 address@hidden
+
+/*!\file
+ * \brief raw file for PDF ewa
+ */
+require_once('invoicing_constant.php');
+extract ($_REQUEST);
+$zip_file=HtmlInput::default_value_request('file','null');
+if ($zip_file=='null')
+{
+    die ('No file asked');
+}
+echo filesize($zip_file);
+header('Content-type: application/zip');
+header('Content-Disposition: attachment; filename="' . basename($file));
+$h_file=fopen($zip_file,"r");
+if ($h_file != true) {
+    die ('cannot open file');
+}
+$buffer=fread ($h_file,filesize($zip_file));
+echo $buffer;
+?>



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]