phpcompta-dev
[Top][All Lists]
Advanced

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

[Phpcompta-dev] r4880 - in phpcompta/trunk: html/js include include/temp


From: phpcompta-dev
Subject: [Phpcompta-dev] r4880 - in phpcompta/trunk: html/js include include/template
Date: Tue, 12 Jun 2012 20:41:28 +0200 (CEST)

Author: danydb
Date: 2012-06-12 20:41:28 +0200 (Tue, 12 Jun 2012)
New Revision: 4880

Modified:
   phpcompta/trunk/html/js/infobulle.js
   phpcompta/trunk/include/cat_document.inc.php
   phpcompta/trunk/include/class_document_type.php
   phpcompta/trunk/include/template/document_mod_change.php
Log:
0000610: Type de document : modification Libell?\195?\169, Pr?\195?\169fixe et 
s?\195?\169quence

Modified: phpcompta/trunk/html/js/infobulle.js
===================================================================
--- phpcompta/trunk/html/js/infobulle.js        2012-06-11 20:50:43 UTC (rev 
4879)
+++ phpcompta/trunk/html/js/infobulle.js        2012-06-12 18:41:28 UTC (rev 
4880)
@@ -42,6 +42,7 @@
 content[12]="Document généré uniquement si le mode de paiement est utilisé";
 content[13]="Vous pouvez utiliser le % pour indiquer le poste parent";
 content[14]="Attention, le poste comptable doit exister, il ne sera pas 
vérifié";
+content[15]="Laissez à 0 pour ne rien changer";
 
 function showBulle(p_ctl)
 {

Modified: phpcompta/trunk/include/cat_document.inc.php
===================================================================
--- phpcompta/trunk/include/cat_document.inc.php        2012-06-11 20:50:43 UTC 
(rev 4879)
+++ phpcompta/trunk/include/cat_document.inc.php        2012-06-12 18:41:28 UTC 
(rev 4880)
@@ -33,6 +33,20 @@
     $catDoc=new Document_Type($cn);
     $catDoc->insert($_POST['cat'],$_POST['prefix']);
 }
+if ( isset($_POST['save'])) {
+       $catDoc=new Document_Type($cn,$_POST['dt_id']);
+       $catDoc->get();
+       $catDoc->dt_value=trim($_POST['dt_name']);
+       $catDoc->dt_prefix=trim($_POST['dt_prefix']);
+       if ( $catDoc->dt_value=="") {
+               alert(_("Le nom ne peut pas être vide"));
+       } else {
+               $catDoc->update();
+       }
+       if ($_POST['seq'] != 0 && isNumber($_POST['seq'])==1){
+               $catDoc->set_number($_POST['seq']);
+       }
+}
 $aList=Document_Type::get_list($cn);
 $addCat=new IText('cat');
 $addPrefix=new IText('prefix');

Modified: phpcompta/trunk/include/class_document_type.php
===================================================================
--- phpcompta/trunk/include/class_document_type.php     2012-06-11 20:50:43 UTC 
(rev 4879)
+++ phpcompta/trunk/include/class_document_type.php     2012-06-12 18:41:28 UTC 
(rev 4880)
@@ -1,4 +1,5 @@
 <?php
+
 /*
  *   This file is part of PhpCompta.
  *
@@ -15,87 +16,124 @@
  *   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
+/* ! \file
  * \brief  class for the table document_type
  */
 
-/*! \brief class for the table document_type
- *< dt_id pk document_type
- *< dt_value value
+/* ! \brief class for the table document_type
+ * < dt_id pk document_type
+ * < dt_value value
  */
 class Document_type
 {
-    /*! document_type
-    * \brief constructor
-    * \param $p_cn database connx
-    */
-    function document_type($p_cn)
-    {
-        $this->db=$p_cn;
-        $this->dt_id=-1;
-    }
-    /*!
-     * \brief Get all the data for this dt_id
-     */
-    function get()
-    {
-        $sql="select * from document_type where dt_id=$1";
-        $R=$this->db->exec_sql($sql,array($this->dt_id));
-        $r=Database::fetch_array($R,0);
-        $this->dt_id=$r['dt_id'];
-        $this->dt_value=$r['dt_value'];
-    }
-    /**
-     address@hidden get a list
-     address@hidden $p_cn database connection
-     address@hidden array of data from document_type
-     */
-    static function get_list($p_cn)
-    {
-        $sql="select * from document_type order by dt_value";
-        $r=$p_cn->get_array($sql);
-        $array=array();
-        for ($i=0;$i<count($r);$i++)
-        {
-            $tmp['dt_value']=$r[$i]['dt_value'];
-            $tmp['dt_prefix']=$r[$i]['dt_prefix'];
+       /* ! document_type
+        * \brief constructor
+        * \param $p_cn database connx
+        */
 
-            $bt=new IButton('X'.$r[$i]['dt_id']);
-            $bt->label=_('Modifier');
-            
$bt->javascript="cat_doc_change('".$r[$i]['dt_id']."','".Dossier::id()."');";
+       function document_type($p_cn, $p_id = -1)
+       {
+               $this->db = $p_cn;
+               $this->dt_id = $p_id;
+       }
 
-            $tmp['js_mod']=$bt->input();
-            $tmp['dt_id']=$r[$i]['dt_id'];
+       /* !
+        * \brief Get all the data for this dt_id
+        */
 
-            $bt=new IButton('X'.$r[$i]['dt_id']);
-            $bt->label=_('Effacer');
-            $bt->javascript="if (confirm('"._('Vous confirmez')."')==true) {";
-            
$bt->javascript.="cat_doc_remove('".$r[$i]['dt_id']."','".Dossier::id()."');";
-            $bt->javascript.='}';
- 
-            $tmp['js_remove']=$bt->input();
+       function get()
+       {
+               $sql = "select * from document_type where dt_id=$1";
+               $R = $this->db->exec_sql($sql, array($this->dt_id));
+               if (count($R) == 0) return 1;
+               $r = Database::fetch_array($R, 0);
+               $this->dt_id = $r['dt_id'];
+               $this->dt_value = $r['dt_value'];
+               $this->dt_prefix = $r['dt_prefix'];
+               return 0;
+       }
 
+       /**
+        * @brief get a list
+        * @parameter $p_cn database connection
+        * @return array of data from document_type
+        */
+       static function get_list($p_cn)
+       {
+               $sql = "select * from document_type order by dt_value";
+               $r = $p_cn->get_array($sql);
+               $array = array();
+               for ($i = 0; $i < count($r); $i++)
+               {
+                       $tmp['dt_value'] = $r[$i]['dt_value'];
+                       $tmp['dt_prefix'] = $r[$i]['dt_prefix'];
 
-            $array[$i]=$tmp;
-        }
-        return $array;
-    }
-    function insert($p_value,$p_prefix)
-    {
-        $sql="insert into document_type(dt_value,dt_prefix) values ($1,$2)";
-        try
-        {
-            if( $this->db->count_sql('select * from document_type where 
upper(dt_value)=upper(trim($1))',array($p_value))>0)
-                throw new Exception('Nom en double');
-            if ( strlen(trim($p_value))>0)
-                $this->db->exec_sql($sql,array($p_value,$p_prefix));
-        }
-        catch (Exception $e)
-        {
-            alert(j(_("Impossible d'ajouter [$p_value] ").$e->getMessage()));
-        }
-    }
+                       $bt = new IButton('X' . $r[$i]['dt_id']);
+                       $bt->label = _('Modifier');
+                       $bt->javascript = "cat_doc_change('" . $r[$i]['dt_id'] 
. "','" . Dossier::id() . "');";
+
+                       $tmp['js_mod'] = $bt->input();
+                       $tmp['dt_id'] = $r[$i]['dt_id'];
+
+                       $bt = new IButton('X' . $r[$i]['dt_id']);
+                       $bt->label = _('Effacer');
+                       $bt->javascript = "if (confirm('" . _('Vous confirmez') 
. "')==true) {";
+                       $bt->javascript.="cat_doc_remove('" . $r[$i]['dt_id'] . 
"','" . Dossier::id() . "');";
+                       $bt->javascript.='}';
+
+                       $tmp['js_remove'] = $bt->input();
+
+
+                       $array[$i] = $tmp;
+               }
+               return $array;
+       }
+
+       function insert($p_value, $p_prefix)
+       {
+               $sql = "insert into document_type(dt_value,dt_prefix) values 
($1,$2)";
+               try
+               {
+                       if ($this->db->count_sql('select * from document_type 
where upper(dt_value)=upper(trim($1))', array($p_value)) > 0)
+                               throw new Exception('Nom en double');
+                       if (strlen(trim($p_value)) > 0)
+                               $this->db->exec_sql($sql, array($p_value, 
$p_prefix));
+               }
+               catch (Exception $e)
+               {
+                       alert(j(_("Impossible d'ajouter [$p_value] ") . 
$e->getMessage()));
+               }
+       }
+
+       /**
+        * Update
+        */
+       function update()
+       {
+               try
+               {
+                       $this->db->exec_sql("update document_type set 
dt_value=$1,dt_prefix=$2 where dt_id=$3", array($this->dt_value,
+                               $this->dt_prefix, $this->dt_id));
+               }
+               catch (Exception $e)
+               {
+                       alert(" Erreur " . $e->getMessage());
+               }
+       }
+
+       function set_number($p_int)
+       {
+               try
+               {
+                       $this->db->exec_sql("alter sequence seq_doc_type_" . 
$this->dt_id . " restart " . $p_int);
+               }
+               catch (Exception $e)
+               {
+                       alert("Erreur " . $e->getMessage());
+               }
+       }
 }

Modified: phpcompta/trunk/include/template/document_mod_change.php
===================================================================
--- phpcompta/trunk/include/template/document_mod_change.php    2012-06-11 
20:50:43 UTC (rev 4879)
+++ phpcompta/trunk/include/template/document_mod_change.php    2012-06-12 
18:41:28 UTC (rev 4880)
@@ -23,13 +23,21 @@
  */
 require_once 'class_document_type.php';
 echo HtmlInput::title_box(_('Type de document'),'change_doc_div');
+
+$doc_type=new Document_type($cn,$dt_id);
+$doc_type->get();
 ?>
-<form method="GET" id="cat_doc_f" 
onsubmit="cat_doc_change_record('cat_doc_f');">
+<form method="POST" id="cat_doc_f" 
onsubmit="cat_doc_change_record('cat_doc_f');">
+       <?=HtmlInput::request_to_hidden(array("ac","gDossier","dt_id"))?>
 <table>
 <tr>
   <td> <?=_('Nom')?>
   </td>
   <td>
+         <?
+         $name=new IText('dt_name',$doc_type->dt_value);
+         echo $name->input();
+         ?>
   </td>
 </tr>
 
@@ -37,14 +45,40 @@
   <td><?=_('Préfixe')?>
   </td>
   <td>
+         <?
+         $prefix=new IText('dt_prefix',$doc_type->dt_prefix);
+         echo $prefix->input();
+         ?>
   </td>
 </tr>
 
 <tr>
-  <td><?=_('Prochain numéro')?>
+  <td><?=_('numéro actuel')?>
   </td>
   <td>
+       <?
+       $ret= $cn->get_array("select last_value,is_called from 
seq_doc_type_".$doc_type->dt_id) ;
+
+    $last=$ret[0]['last_value'];
+             /*!
+                  *\note  With PSQL sequence , the last_value column is 1 when 
before   AND after the first call, to make the difference between them
+                  * I have to check whether the sequence has been already 
called or not */
+    if ($ret[0]['is_called']=='f' ) $last--;
+       echo $last;
+       ?>
   </td>
+  <tr>
+  <td><?=_('Prochain numéro')?>
+         <?=
+               HtmlInput::infobulle(15);
+       ?>
+  </td>
+   <td>
+         <?
+         $seq=new INum('seq',0);
+         echo $seq->input();
+         ?>
+  </td>
 </tr>
 
 </table>



---
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]