diff --git a/doc/manuel-fr.odt b/doc/manuel-fr.odt index c5c49f684..9f4d8705f 100644 Binary files a/doc/manuel-fr.odt and b/doc/manuel-fr.odt differ diff --git a/doc/manuel-fr.pdf b/doc/manuel-fr.pdf index 3843ec067..328cfb0c1 100644 Binary files a/doc/manuel-fr.pdf and b/doc/manuel-fr.pdf differ diff --git a/html/admin/sql/patch/upgrade101.sql b/html/admin/sql/patch/upgrade101.sql new file mode 100644 index 000000000..b79c0f553 --- /dev/null +++ b/html/admin/sql/patch/upgrade101.sql @@ -0,0 +1,11 @@ +begin; +delete from letter_deb where ld_id in (select a.ld_id from letter_deb as a join letter_deb as b on (a.j_id=b.j_id and a.ld_id > b.ld_id)); +delete from letter_cred where lc_id in (select a.lc_id from letter_cred as a join letter_cred as b on (a.j_id=b.j_id and a.lc_id > b.lc_id)); + +ALTER TABLE letter_deb ADD CONSTRAINT letter_deb_j_id_key UNIQUE(j_id ); +ALTER TABLE letter_cred ADD CONSTRAINT letter_cred_j_id_key UNIQUE(j_id ); + + +update version set val=102; + +commit; \ No newline at end of file diff --git a/html/ajax_history.php b/html/ajax_history.php index 265896e6e..78bb9f24f 100644 --- a/html/ajax_history.php +++ b/html/ajax_history.php @@ -44,7 +44,7 @@ $user=new User($cn); /* security */ if ( $user->check_dossier(dossier::id(),true) == 'X' ) exit(); - +$from_div=(isset ($_REQUEST['ajax']))?1:0; /////////////////////////////////////////////////////////////////////////// /* first detail for a card */ @@ -87,7 +87,7 @@ if ( isset($_GET['f_id'])) $obj="{div:'$div',f_id:'".$_GET['f_id']."',gDossier:'$dossier',select:this}"; $is=$exercice->select('p_exercice',$default,' onchange="update_history_card('.$obj.');"'); $old="Autre exercice ".$is->input(); - } + } else { $old='
'; @@ -108,7 +108,7 @@ if ( isset($_GET['f_id'])) echo h2info( $fiche->getName().'['.$fiche->strAttribut(ATTR_DEF_QUICKCODE).']'); echo '

'.$detail_card.'

'; - if ( $fiche->HtmlTable($array,0,0)==-1){ + if ( $fiche->HtmlTable($array,0,$from_div)==-1){ echo h2("Aucune opération pour l'exercice courant",'class="error"'); } diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php index 26749293c..a152661b9 100644 --- a/html/ajax_ledger.php +++ b/html/ajax_ledger.php @@ -48,8 +48,8 @@ if ( ! isset ($_REQUEST['act'])|| ! isset ($_REQUEST['jr_id']) exit(); } global $g_parameter; - - + + $action=$_REQUEST['act']; $jr_id=$_REQUEST['jr_id']; $div=$_REQUEST['div']; /* the div source and target for javascript */ @@ -188,15 +188,22 @@ case 'file': echo ""; $repo=new Database(); $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; + echo ""; + if ( ! isset($_REQUEST['ajax']) ) { + echo ""; + echo '
'; + }else { + echo ""; + echo "
"; + } + echo "

Document

"; if ( $access=='W') { echo ''; + $sp=new ISpan('file'.$div); - $sp->style="display:none;width:155;height:15;background-color:red;color:white;font-size:10"; + $sp->style="display:none;background-color:red;color:white;font-size:12px"; $sp->value="Chargement"; echo $sp->input(); echo HtmlInput::hidden('act','loadfile'); @@ -209,18 +216,28 @@ case 'file': } else { - echo ""; - $repo=new Database(); - $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); - echo " "; - echo ""; - echo '
'; + echo ""; + if (!isset($_REQUEST['ajax'])) + { + echo ""; + echo '
'; + } + else + { + echo ""; + echo "
"; + } + $repo = new Database(); + $theme = $repo->get_value("select the_filestyle from theme where the_name=$1", array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; - echo _('Aucun fichier'); - } - echo '
'; - echo ''; - exit(); + echo _('Aucun fichier'); + } + echo '
'; + echo ''; + exit(); } else { @@ -228,12 +245,20 @@ case 'file': $repo=new Database(); $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); echo " "; - echo ""; - echo '
'; + echo ""; + if ( ! isset($_REQUEST['ajax']) ) { + echo ""; + echo '
'; + }else { + echo ""; + echo "
"; + } + echo "

Document

"; + echo '
'; $x=''; if ($access=='W') - $x=sprintf('enlever', + $x=sprintf('enlever', $gDossier,$div,$jr_id); echo $x; $filename= $obj->det->jr_pj_name; @@ -268,15 +293,13 @@ case 'loadfile': $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); echo " "; echo ""; + if ( ! isset($_REQUEST['ajax']) ) echo ""; else echo ""; + echo "

Document

"; echo '
'; - $x=sprintf('enlever', + $x=sprintf('enlever', $gDossier,$div,$jr_id); echo $x; $filename= $obj->det->jr_pj_name; - if ( strlen($obj->det->jr_pj_name) > 20 ) - { - $filename=substr($obj->det->jr_pj_name,1,20); - } $h=sprintf('%s', $gDossier,$ledger,$obj->det->jr_grpt_id,h($filename)); echo $h; @@ -294,9 +317,9 @@ case 'rmf': $repo=new Database(); $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); echo " "; - echo ""; + echo ""; + echo "

Document

"; echo '
'; - echo ''; $sp=new ISpan('file'.$div); $sp->style="display:none;width:155;height:15;background-color:red;color:white;font-size:10"; @@ -368,7 +391,7 @@ case 'save': $cn->exec_sql("select comptaproc.jrn_add_note($1,$2)", array($jr_id,$_POST['jrn_note'])); $rapt=$_POST['rapt']; - + if ( $g_parameter->MY_UPDLAB=='Y' && isset ($_POST['j_id'])) { $a_rowid=$_POST["j_id"]; diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index be984704a..72c9c7750 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -248,6 +248,7 @@ function ledger_fin_add_row() var tt=rowToCopy.cells[e].innerHTML; var new_tt=tt.replace(/e_other0/g,"e_other"+nb.value); new_tt=new_tt.replace(/e_other0_comment/g,"e_other"+nb.value+'_comment'); + new_tt=new_tt.replace(/e_other_name0/g,"e_other_name"+nb.value); new_tt=new_tt.replace(/e_other0_amount/g,"e_other"+nb.value+'_amount'); new_tt=new_tt.replace(/e_concerned0/g,"e_concerned"+nb.value); new_tt=new_tt.replace(/e_other0_label/g,"e_other"+nb.value+'_label'); @@ -255,6 +256,7 @@ function ledger_fin_add_row() new_tt.evalScripts(); } g("e_other"+nb.value).value=""; + g("e_other_name"+nb.value).value=""; g("e_other"+nb.value+'_amount').value="0"; g("e_other"+nb.value+'_comment').value=""; g("e_concerned"+nb.value).value=""; @@ -881,7 +883,7 @@ function op_save(obj) onSuccess:infodiv } ); - window.close(); + // window.close(); } else { diff --git a/html/style-color.css b/html/style-color.css index 6f88b88a7..6ca9bdb3b 100644 --- a/html/style-color.css +++ b/html/style-color.css @@ -886,7 +886,7 @@ h2.gest_name { border-right:1px solid #b4bbc2; padding: 5px; } -div.op_detail_frame { +body.op_detail_frame ,div.op_detail_frame { background-color:#e4e7ed; height:100%; width:100%; diff --git a/html/style-epad.css b/html/style-epad.css index 58beef6dd..41b5db27b 100644 --- a/html/style-epad.css +++ b/html/style-epad.css @@ -881,7 +881,7 @@ h2.gest_name { border-right:1px solid #b4bbc2; padding: 5px; } -div.op_detail_frame { +body.op_detail_frame ,div.op_detail_frame { background-color:#e4e7ed; height:100%; width:100%; diff --git a/html/style-light.css b/html/style-light.css index f89489818..2ace07d64 100644 --- a/html/style-light.css +++ b/html/style-light.css @@ -882,7 +882,7 @@ h2.gest_name { border-right:1px solid #b4bbc2; padding: 5px; } -div.op_detail_frame { +body.op_detail_frame,div.op_detail_frame { background-color:#e4e7ed; height:100%; width:100%; diff --git a/html/style.css b/html/style.css index 3752cb561..ab2241cc5 100644 --- a/html/style.css +++ b/html/style.css @@ -877,7 +877,7 @@ h2.gest_name { border-right:1px solid #b4bbc2; padding: 5px; } -div.op_detail_frame { +body.op_detail_frame,div.op_detail_frame { background-color:#e4e7ed; height:100%; width:100%; diff --git a/include/ac_common.php b/include/ac_common.php index 0c0e16735..b326e2d9b 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -278,6 +278,17 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") { $style = "style.css"; } // end if + $title="PhpCompta"; + + if ( isset ($_REQUEST['ac'])) { + if (strpos($_REQUEST['ac'],'/') <> 0) + { + $m= explode('/',$_REQUEST['ac']); + $title=$m[count($m)-1]." ".$title; + } + else + $title=$_REQUEST['ac']." ".$title; + } echo ''; echo ""; @@ -285,7 +296,7 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") $p_script2 = ''; echo " - PhpCompta + $title " . @@ -698,15 +709,37 @@ function smaller_date($p_date) /** * @brief format the date, when taken from the database the format * is MM-DD-YYYY - * @param $p_date format YYYY-MM-DD + * @param $p_date format + * @param * @return date in the format DD.MM.YYYY */ -function format_date($p_date) +function format_date($p_date, $p_from_format = 'YYYY-MM-DD',$p_to_format='DD.MM.YYYY') { - $date = explode('-', $p_date); - if (count($date) != 3) - return $p_date; - $str_date = $date[2] . '.' . $date[1] . '.' . $date[0]; + if ($p_from_format == 'YYYY-MM-DD') + { + $date = explode('-', $p_date); + if (count($date) != 3) + return $p_date; + } + if ($p_from_format == 'DD.MM.YYYY') + { + $temp_date = explode('.', $p_date); + if (count($temp_date) != 3) + return $p_date; + $date[0] = $temp_date[2]; // 0 is year + $date[1] = $temp_date[1]; // 1 for month + $date[2] = $temp_date[0]; // 2 for day + } + + switch ($p_to_format) + { + case 'DD.MM.YYYY': + $str_date = $date[2] . '.' . $date[1] . '.' . $date[0]; + break; + case 'YYYY-MM-DD': + $str_date = $date[0] . '-' . $date[1] . '-' . $date[2]; + break; + } return $str_date; } diff --git a/include/action.common.inc.php b/include/action.common.inc.php index f4b5b6fd2..a1d9ec14b 100644 --- a/include/action.common.inc.php +++ b/include/action.common.inc.php @@ -56,7 +56,7 @@ if ( isset($_POST['generate'])) { $act->Update(); } - $act->generate_document($_POST['doc_mod']); + $act->generate_document($_POST['doc_mod'],$_POST); $sub_action='detail'; } /* for delete */ @@ -275,7 +275,7 @@ function ShowActionList($cn,$p_base) /* type of documents */ $type_doc=new ISelect ('tdoc'); - $aTDoc=$cn->make_array('select dt_id,dt_value from document_type'); + $aTDoc=$cn->make_array('select dt_id,dt_value from document_type order by dt_value'); $aTDoc[]=array('value'=>'-1','label'=>_('Tous les types')); $type_doc->value=$aTDoc; $type_doc->selected=(isset ($_GET['tdoc']))?$_GET['tdoc']:-1; diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php index 1d9411013..0ce0971bf 100644 --- a/include/class_acc_account_ledger.php +++ b/include/class_acc_account_ledger.php @@ -315,7 +315,7 @@ class Acc_Account_Ledger * \param $let lettering of operation 0 * \return -1 if nothing is found otherwise 0 */ - function HtmlTable($p_array=null,$let=0 ) + function HtmlTable($p_array=null,$let=0 , $from_div=0) { if ( $p_array==null)$p_array=$_REQUEST; $this->get_name(); @@ -329,13 +329,16 @@ class Acc_Account_Ledger $rep=""; echo '

'.$this->id." ".$this->name.'

'; - echo ""; + if ( $from_div == 0) + echo "
"; + else + echo "
"; echo ''; echo "". - "". - "". - "". - "". + "". + "". + "". + "". "". "". th('Prog.','style="text-align:right"'). @@ -345,6 +348,7 @@ class Acc_Account_Ledger $progress=0;$sum_deb=0;$sum_cred=0; bcscale(2); $old_exercice=""; + $idx=0; foreach ( $this->row as $op ) { $vw_operation=sprintf('%s', @@ -381,9 +385,11 @@ class Acc_Account_Ledger $progress=bcadd($progress,$tmp_diff); $sum_cred=bcadd($sum_cred,$op['cred_montant']); $sum_deb=bcadd($sum_deb,$op['deb_montant']); + if ($idx%2 == 0) $class='class="odd"'; else $class=' class="even"'; + $idx++; - echo "". - "". + echo "". + "". td(h($op['jr_pj_number'])). "". "". @@ -606,6 +612,16 @@ class Acc_Account_Ledger $sql=substr($sql,0,strlen($sql)-2); return $sql; } + /** + * Find the card which is using the current account + * @return an array of f_id + */ + function find_card() + { + $sql="select f_id from fiche_detail where ad_id=$1 and ad_value=$2"; + $account=$this->db->get_array($sql,array(ATTR_DEF_ACCOUNT,$this->id)); + return $account; + } static function test_me() { $cn=new Database(dossier::id()); diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 5e0849b92..662f76bba 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -136,6 +136,22 @@ class Acc_Ledger extends jrn_def_sql $this->db->exec_sql('delete from jrn where jr_id=$1', array($this->jr_id)); } + /** + *Display warning contained in an array + * @return string with error message + */ + function display_warning($pa_msg,$p_warning) + { + $str='

'.$p_warning; + $str.="

    "; + for ($i=0;$i"; + } + $str.='
'; + $str.='

'; + return $str; + } /** * reverse the operation by creating the opposite one, * the result is to avoid it @@ -1330,7 +1346,8 @@ class Acc_Ledger extends jrn_def_sql function confirm($p_array,$p_readonly=false) { global $g_parameter; - if (! $p_readonly ) $this->verify($p_array); + $msg=array(); + if (! $p_readonly ) $msg=$this->verify($p_array); $this->id=$p_array['p_jrn']; if ( empty($p_array)) return 'Aucun résultat'; $anc=null; @@ -1348,6 +1365,10 @@ class Acc_Ledger extends jrn_def_sql bcscale(2); $ret=""; + if ( ! empty ($msg)) + { + $ret.=$this->display_warning($msg,"Attention : il vaut mieux utiliser les fiches que les postes comptables pour"); + } $ret.="
Date n° de pièce Code interne Description Date n° de pièce Code interne Description Débit Crédit
".format_date($op['j_date'])."
".smaller_date(format_date($op['j_date']))."".$vw_operation."".h($op['description'])."
"; $ret.=""; /* display periode */ @@ -1655,7 +1676,7 @@ class Acc_Ledger extends jrn_def_sql $poste->value=(isset(${'poste'.$i}))?${"poste".$i}:'' ; $poste->dbl_click_history(); - + $poste->readonly=$p_readonly; if ( $poste->value != '' ) @@ -1740,6 +1761,7 @@ class Acc_Ledger extends jrn_def_sql $user=new User($this->db); $tot_cred=0; $tot_deb=0; + $msg=array(); /* check if we can write into this ledger */ $user=new User($this->db); @@ -1831,6 +1853,19 @@ class Acc_Ledger extends jrn_def_sql throw new Exception(_('Poste invalide ['.${'poste'.$i}.']'),3); if ( $p->do_exist() == 0 ) throw new Exception(_('Poste Inexistant ['.${'poste'.$i}.']'),4); + $card_id=$p->find_card() ; + if (! empty($card_id) ) + { + $str_msg=" Le poste ".$p->id." appartient à ".count($card_id)." fiche(s) dont :"; + $max=(count($card_id)>MAX_COMPTE_CARD)?MAX_COMPTE_CARD:count($card_id); + for ($x=0;$x < $max;$x++) + { + $card=new Fiche($this->db,$card_id[$x]['f_id']); + $str_msg.=HtmlInput::card_detail($card->strAttribut(ATTR_DEF_QUICKCODE),$card->strAttribut(ATTR_DEF_NAME),'style="color:red;display:inline;text-decoration:underline"'); + $str_msg.=" "; + } + $msg[]=$str_msg; + } } @@ -1842,6 +1877,7 @@ class Acc_Ledger extends jrn_def_sql throw new Exception(_("Balance incorrecte ")." debit = $tot_deb credit=$tot_cred ",1); } + return $msg; } /*! * \brief compute the internal code of the saved operation and set the $this->jr_internal to @@ -1879,8 +1915,11 @@ class Acc_Ledger extends jrn_def_sql extract ($p_array); try { - $this->verify($p_array); - + $msg=$this->verify($p_array); + if ( ! empty ($msg)) + { + echo $this->display_warning($msg,"Attention : il vaut mieux utiliser les fiches que les postes comptables pour"); + } $this->db->start() ; $seq=$this->db->get_next_seq('s_grpt'); @@ -2213,7 +2252,7 @@ class Acc_Ledger extends jrn_def_sql $doc->f_id=$e_client; $doc->md_id=$gen_doc; $doc->ag_id=0; - $doc->Generate(); + $doc->Generate($p_array); // Move the document to the jrn $doc->MoveDocumentPj($internal); // Update the comment with invoice number, if the comment is empty diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php index 9436185ef..9292efa3a 100644 --- a/include/class_acc_ledger_fin.php +++ b/include/class_acc_ledger_fin.php @@ -327,7 +327,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $W1->set_attribute('ipopup','ipopcard'); // name of the field to update with the name of the card - $W1->set_attribute('label','e_other'.$i.'_comment'); + $W1->set_attribute('label','e_other_name'.$i); // name of the field to update with the name of the card $W1->set_attribute('typecard','filter'); // Add the callback function to filter the card on the jrn @@ -339,6 +339,21 @@ class Acc_Ledger_Fin extends Acc_Ledger $array[$i]['qcode']=$W1->input(); $array[$i]['search']=$W1->search(); + // Card name + // + $card_name=""; + if ( $tiers !="" ) + { + $fiche=new Fiche($this->db); + $fiche->get_by_qcode($tiers); + $card_name=$this->db->get_value("Select ad_value from fiche_detail where ad_id=$1 and f_id=$2", + array(ATTR_DEF_NAME,$fiche->id)); + } + + $wcard_name=new IText("e_other_name".$i,$card_name); + $wcard_name->readOnly=true; + $array[$i]['cname']=$wcard_name->input(); + // Comment $wComment=new IText("e_other$i"."_comment",$tiers_comment); @@ -463,8 +478,8 @@ class Acc_Ledger_Fin extends Acc_Ledger //------------------------------------------------- $r.='
"._('Date')." : $e_date
'; $r.=""; - $r.=""; - $r.=""; + $r.=""; + $r.=""; $r.=""; $r.=''; diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index ddeaad489..ed74c1919 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -724,7 +724,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger { $ref_doc= $this->create_document($internal,$p_array); $this->doc= _('Document généré')." : "."
"; - $this->doc.=''.$ref_doc.''; + $this->doc.=''.$ref_doc.''; } //---------------------------------------- diff --git a/include/class_anc_grandlivre.php b/include/class_anc_grandlivre.php index 793278040..95f073dcf 100644 --- a/include/class_anc_grandlivre.php +++ b/include/class_anc_grandlivre.php @@ -79,7 +79,7 @@ class Anc_GrandLivre extends Anc_Print left join jrnx using (j_id) left join jrn on (j_grpt=jr_grpt_id) where $pa_id_cond oa_amount <> 0.0 $cond_poste $filter_date - order by po_name,to_date(oa_date,'DD.MM.YYYY') ,qcode,j_poste"); + order by po_name,oa_date::date,qcode,j_poste"); return $array; } @@ -108,7 +108,7 @@ class Anc_GrandLivre extends Anc_Print left join jrnx using (j_id) left join jrn on (j_grpt=jr_grpt_id) where $pa_id_cond oa_amount <> 0.0 $cond_poste $filter_date - order by po_name,to_date(oa_date,'DD.MM.YYYY') ,qcode,j_poste"); + order by po_name,oa_date::date,qcode,j_poste"); return $array; diff --git a/include/class_anc_operation.php b/include/class_anc_operation.php index 1c5046dc1..b33300dda 100644 --- a/include/class_anc_operation.php +++ b/include/class_anc_operation.php @@ -547,7 +547,7 @@ class Anc_Operation * -oa_description * */ - function save_form_plan($p_array,$p_item,$j_id) + function save_form_plan($p_array,$p_item,$p_j_id) { extract($p_array); if (! isset ($hplan) ) return; @@ -576,7 +576,7 @@ class Anc_Operation $op=new Anc_Operation($this->db); $op->po_id=$hplan[$p_item][$e]; $op->oa_group=$this->oa_group; - $op->j_id=$j_id; + $op->j_id=$p_j_id; $op->oa_amount=abs($val[$p_item][$row]); $op->oa_debit=$this->oa_debit; $op->oa_date=$this->oa_date; diff --git a/include/class_calendar.php b/include/class_calendar.php index 54156cec5..4c9bb554a 100644 --- a/include/class_calendar.php +++ b/include/class_calendar.php @@ -122,10 +122,10 @@ class Calendar $cn=new Database(dossier::id()); $array=$cn->get_array("select to_char(p_start,'MM') as month, to_char(p_start,'YYYY') as year ". " from parm_periode where p_id=$1",array($this->default_periode)); - $this->month=$array[0]['month']; - $this->year=$array[0]['year']; + $this->month=(int)$array[0]['month']; + $this->year=(int)$array[0]['year']; $this->day=self::$nb_day[$this->month-1]; - if ( $this->year % 4 == 0 && $this->month=2) + if ( $this->year % 4 == 0 && $this->month==2) $this->day=29; } /** diff --git a/include/class_document.php b/include/class_document.php index 463a6ed48..4b4384ed0 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -66,12 +66,12 @@ class Document /*! * \brief Generate the document, Call $this-\>Replace to replace * tag by value - * + *\p_array contains the data normally it is the $_POST * * \return an array : the url where the generated doc can be found, the name * of the file and his mimetype */ - function Generate() + function Generate($p_array) { // create a temp directory in /tmp to unpack file and to parse it $dirname=tempnam($_ENV['TMP'],'doc_'); @@ -123,7 +123,7 @@ class Document $this->d_number=$this->db->get_next_seq("seq_doc_type_".$row['md_type']); // parse the document - return the doc number ? - $this->ParseDocument($dirname,$file_to_parse,$type); + $this->ParseDocument($dirname,$file_to_parse,$type,$p_array); $this->db->commit(); // if the doc is a OOo, we need to re-zip it @@ -161,8 +161,9 @@ class Document * \param $p_dir directory name * \param $p_file filename * \param $p_type For the OOo document the tag are < and > instead of < and > + * \param $p_array variable from $_POST */ - function ParseDocument($p_dir,$p_file,$p_type) + function ParseDocument($p_dir,$p_file,$p_type,$p_array) { /*!\note Replace in the doc the tags by their values. @@ -239,7 +240,7 @@ class Document // if the pattern if found we replace it - $value=$this->Replace($pattern); + $value=$this->Replace($pattern,$p_array); if ( strpos($value,'ERROR') != false ) $value=""; // replace into the $buffer // take the position in the buffer @@ -467,7 +468,10 @@ class Document * - [VEN_TVAC] * - [VEN_TVA] * - [TOTAL_VEN_HTVA] + * - [DATE_CALC] * - [DATE] + * - [DATE_LIMIT] + * - [DATE_LIMIT_CALC] * - [NUMBER] * - [MY_NAME] * - [MY_CP] @@ -494,9 +498,10 @@ class Document * - [BENEF_VAT] * * \param $p_tag TAG + * \param $p_array data from $_POST * \return String which must replace the tag */ - function Replace($p_tag) + function Replace($p_tag,$p_array) { $p_tag=strtoupper($p_tag); $p_tag=str_replace('=','',$p_tag); @@ -504,15 +509,21 @@ class Document static $counter=0; switch ($p_tag) { - case 'DATE': + case 'DATE': + $r=(isset ($p_array['ag_timestamp']))?$p_array['ag_timestamp']:$p_array['e_date']; + break; + case 'DATE_CALC': $r=' Date inconnue '; - // Date are in $_REQUEST['ag_date'] - // or $_POST['e_date'] - if ( isset ($_REQUEST['ag_timestamp'])) - $r=$_REQUEST['ag_timestamp']; - if ( isset ($_REQUEST['e_date'])) - $r=$_REQUEST['e_date']; - + // Date are in $p_array['ag_date'] + // or $p_array['e_date'] + if ( isset ($p_array['ag_timestamp'])) { + $date=format_date($p_array['ag_timestamp'],'DD.MM.YYYY','YYYY-MM-DD'); + $r=$date; + } + if ( isset ($p_array['e_date'])) { + $date=format_date($p_array['e_date'],'DD.MM.YYYY','YYYY-MM-DD'); + $r=$date; + } break; // // the company priv @@ -555,12 +566,12 @@ class Document break; // customer - /*\note The CUST_* are retrieved thx the $_REQUEST['tiers'] + /*\note The CUST_* are retrieved thx the $p_array['tiers'] * which contains the quick_code */ case 'SOLDE': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $p=$tiers->strAttribut(ATTR_DEF_ACCOUNT); $poste=new Acc_Account_Ledger($this->db,$p); @@ -568,13 +579,13 @@ class Document break; case 'CUST_NAME': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_NAME); break; case 'CUST_ADDR_1': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_ADRESS); @@ -582,7 +593,7 @@ class Document case 'CUST_CP': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_CP); @@ -590,7 +601,7 @@ class Document case 'CUST_CITY': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_CITY); @@ -599,35 +610,35 @@ class Document case 'CUST_CO': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_PAYS); break; - // Marchandise in $_POST['e_march*'] + // Marchandise in $p_array['e_march*'] // \see user_form_achat.php or user_form_ven.php case 'CUST_VAT': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_NUMTVA); break; case 'CUST_NUM': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER); break; case 'CUST_BANQUE_NO': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_BQ_NO); break; case 'CUST_BANQUE_NAME': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; + $qcode=isset($p_array['qcode_dest'])?$p_array['qcode_dest']:$p_array['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_BQ_NAME); break; @@ -635,7 +646,7 @@ class Document /* BENEFIT (fee notes */ case 'BENEF_NAME': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -646,7 +657,7 @@ class Document break; case 'BENEF_ADDR_1': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -659,7 +670,7 @@ class Document case 'BENEF_CP': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -672,7 +683,7 @@ class Document case 'BENEF_CITY': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -686,7 +697,7 @@ class Document case 'BENEF_CO': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -696,12 +707,12 @@ class Document $r=$tiers->strAttribut(ATTR_DEF_PAYS); break; - // Marchandise in $_POST['e_march*'] + // Marchandise in $p_array['e_march*'] // \see user_form_achat.php or user_form_ven.php case 'BENEF_VAT': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -712,7 +723,7 @@ class Document break; case 'BENEF_NUM': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -723,7 +734,7 @@ class Document break; case 'BENEF_BANQUE_NO': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -734,7 +745,7 @@ class Document break; case 'BENEF_BANQUE_NAME': $tiers=new Fiche($this->db); - $qcode=isset($_REQUEST['qcode_benef'])?$_REQUEST['qcode_benef']:''; + $qcode=isset($p_array['qcode_benef'])?$p_array['qcode_benef']:''; if ( $qcode=='') { $r=''; @@ -744,7 +755,7 @@ class Document $r=$tiers->strAttribut(ATTR_DEF_BQ_NAME); break; - // Marchandise in $_POST['e_march*'] + // Marchandise in $p_array['e_march*'] // \see user_form_achat.php or user_form_ven.php case 'NUMBER': $r=$this->d_number; @@ -774,20 +785,25 @@ class Document * - [TOTAL_VEN_HTVA] * - [DATE_LIMIT] */ - case 'DATE_LIMIT': - extract ($_POST); + case 'DATE_LIMIT_CALC': + extract ($p_array); + $id='e_ech' ; + if ( !isset (${$id}) ) return ""; + $r=format_date(${$id},'DD.MM.YYYY','YYYY-MM-DD'); + break; + case 'DATE_LIMIT': + extract ($p_array); $id='e_ech' ; if ( !isset (${$id}) ) return ""; $r=${$id}; break; - case 'MARCH_NEXT': $counter++; $r=''; break; case 'VEN_ART_NAME': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter; // check if the march exists if ( ! isset (${$id})) return ""; @@ -801,7 +817,7 @@ class Document else $r = ""; break; case 'VEN_ART_LABEL': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter."_label"; // check if the march exists @@ -826,15 +842,16 @@ class Document break; case 'VEN_ART_PRICE': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter.'_price' ; if ( !isset (${$id}) ) return ""; + if (${$id} == 0 ) return ""; $r=${$id}; break; case 'TVA_RATE': case 'VEN_ART_TVA_RATE': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter.'_tva_id'; if ( !isset (${$id}) ) return ""; if ( ${$id} == -1 || ${$id}=='' ) return ""; @@ -848,7 +865,7 @@ class Document case 'TVA_CODE': case 'VEN_ART_TVA_CODE': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter.'_tva_id'; if ( !isset (${$id}) ) return ""; if ( ${$id} == -1 ) return ""; @@ -863,7 +880,7 @@ class Document break; case 'TVA_LABEL': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter.'_tva_id'; if ( !isset (${$id}) ) return ""; $march_id='e_march'.$counter.'_price' ; @@ -877,7 +894,7 @@ class Document /* total VAT for one sold */ case 'TVA_AMOUNT': - extract ($_POST); + extract ($p_array); $qt='e_quant'.$counter; $price='e_march'.$counter.'_price' ; $tva='e_march'.$counter.'_tva_id'; @@ -893,7 +910,7 @@ class Document break; /* TVA automatically computed */ case 'VEN_ART_TVA': - extract ($_POST); + extract ($p_array); $qt='e_quant'.$counter; $price='e_march'.$counter.'_price' ; $tva='e_march'.$counter.'_tva_id'; @@ -910,7 +927,7 @@ class Document break; case 'VEN_ART_TVAC': - extract ($_POST); + extract ($p_array); $qt='e_quant'.$counter; $price='e_march'.$counter.'_price' ; $tva='e_march'.$counter.'_tva_id'; @@ -934,7 +951,7 @@ class Document break; case 'VEN_ART_QUANT': - extract ($_POST); + extract ($p_array); $id='e_quant'.$counter; if ( !isset (${$id}) ) return ""; // check that something is sold @@ -947,7 +964,7 @@ class Document break; case 'VEN_HTVA': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter.'_price' ; $quant='e_quant'.$counter; if ( !isset (${$id}) ) return ""; @@ -962,30 +979,26 @@ class Document break; case 'VEN_TVAC': - extract ($_POST); + extract ($p_array); $id='e_march'.$counter.'_tva_amount' ; $price='e_march'.$counter.'_price' ; $quant='e_quant'.$counter; - if ( ! isset(${'e_march'.$counter.'_price'})|| !isset(${'e_quant'.$counter})) - return ""; + if ( ! isset(${'e_march'.$counter.'_price'})|| !isset(${'e_quant'.$counter})) return ""; // check that something is sold - if ( ${'e_march'.$counter.'_price'} == 0 || ${'e_quant'.$counter} == 0 ) - return ""; - - - // if it is exist + if ( ${'e_march'.$counter.'_price'} == 0 || ${'e_quant'.$counter} == 0 ) return ""; + bcscale(2); + // if TVA not exist if ( ! isset(${$id})) - $r=round(${$price}*${$quant},2); - else - $r=round($ - { - $price - } - *${$quant}+$id,2); + $r= bcmul(${$price},${$quant}); + else{ + $r= bcmul(${$price},${$quant}); + $r=bcadd($r,${$id}); + } + return $r; break; case 'TOTAL_VEN_HTVA': - extract($_POST); + extract($p_array); $sum=0.0; for ($i=0;$i<$nb_item;$i++) @@ -1007,8 +1020,9 @@ class Document $r=round($sum,2); break; case 'TOTAL_VEN_TVAC': - extract($_POST); + extract($p_array); $sum=0.0; + bcscale(2); for ($i=0;$i<$nb_item;$i++) { $tva='e_march'.$i.'_tva_amount'; @@ -1020,16 +1034,15 @@ class Document } $sell=${'e_march'.$i.'_price'}; $qt=${'e_quant'.$i}; - - - $sum+=$sell*$qt+$tva_amount; - $sum=round($sum,2); + $tot=bcmul($sell,$qt); + $tot=bcadd($tot,$tva_amount); + $sum=bcadd($sum,$tot); } $r=round($sum,2); break; case 'TOTAL_TVA': - extract($_POST); + extract($p_array); $sum=0.0; for ($i=0;$i<$nb_item;$i++) { @@ -1046,26 +1059,26 @@ class Document break; case 'BON_COMMANDE': - if ( isset($_REQUEST['bon_comm'])) - return $_REQUEST['bon_comm']; + if ( isset($p_array['bon_comm'])) + return $p_array['bon_comm']; else return ""; break; case 'PJ': - if ( isset($_REQUEST['e_pj'])) - return $_REQUEST['e_pj']; + if ( isset($p_array['e_pj'])) + return $p_array['e_pj']; else return ""; case 'OTHER_INFO': - if ( isset($_REQUEST['other_info'])) - return $_REQUEST['other_info']; + if ( isset($p_array['other_info'])) + return $p_array['other_info']; else return ""; break; case 'COMMENT': - if ( isset($_REQUEST['e_comm'])) - return $_REQUEST['e_comm']; + if ( isset($p_array['e_comm'])) + return $p_array['e_comm']; break; } return $r; diff --git a/include/class_document_modele.php b/include/class_document_modele.php index e047684ec..ad9d7eaf8 100644 --- a/include/class_document_modele.php +++ b/include/class_document_modele.php @@ -248,7 +248,7 @@ class Document_modele $w=new ISelect(); $w->name="md_type"; - $w->value=$this->cn->make_array('select dt_id,dt_value from document_type'); + $w->value=$this->cn->make_array('select dt_id,dt_value from document_type order by dt_value'); $r.=""; $r.=''; diff --git a/include/class_document_type.php b/include/class_document_type.php index be5663fcc..373b78dae 100644 --- a/include/class_document_type.php +++ b/include/class_document_type.php @@ -55,7 +55,7 @@ class Document_type */ static function get_list($p_cn) { - $sql="select * from document_type"; + $sql="select * from document_type order by dt_value"; $r=$p_cn->get_array($sql); $array=array(); for ($i=0;$iad_id); $w->set_attribute('ipopup','ipop_account'); $w->set_attribute('account',"av_text".$attr->ad_id); + $w->dbl_click_history(); // account created automatically $sql="select account_auto($p_fiche_def)"; $ret_sql=$this->cn->exec_sql($sql); @@ -492,6 +493,7 @@ class Fiche break; case 'numeric': $w = new INum(); + $w->javascript='onchange="format_number(this,4);"'; $w->size = $attr->ad_size; break; case 'date': @@ -587,6 +589,7 @@ class Fiche $w = new IPoste("av_text" . $r->ad_id); $w->set_attribute('ipopup', 'ipop_account'); $w->set_attribute('account', "av_text" . $r->ad_id); + $w->dbl_click_history(); // account created automatically $w->table = 0; $w->value = $r->av_text; @@ -635,6 +638,7 @@ class Fiche case 'numeric': $w = new INum('av_text' . $r->ad_id); $w->size = $r->ad_size; + $w->javascript='onchange="format_number(this,4);"'; $w->value = $r->av_text; break; case 'date': @@ -651,6 +655,7 @@ class Fiche $w = new IPoste("av_text" . $r->ad_id); $w->set_attribute('ipopup', 'ipop_account'); $w->set_attribute('account', "av_text" . $r->ad_id); + $w->dbl_click_history(); $w->width = $r->ad_size; $w->table = 0; $bulle = HtmlInput::infobulle(14); @@ -1302,19 +1307,18 @@ class Fiche $rep=""; if ( $from_div==1) { - echo '

'." ".$name.'

'; echo "
NomCommentaireNomCommentaireMontant Op. Concernée(s)".$w->input()."
"; } else { - echo "
"; + echo "
"; } echo ''; echo "". - "". - "". - "". - "". + "". + "". + "". + "". "". "". th('Prog.','style="text-align:right"'). @@ -1323,6 +1327,7 @@ class Fiche ; $old_exercice="";$sum_deb=0;$sum_cred=0; bcscale(2); + $idx=0; foreach ( $this->row as $op ) { $vw_operation=sprintf('%s', @@ -1359,9 +1364,11 @@ class Fiche $progress=bcadd($progress,$tmp_diff); $sum_cred=bcadd($sum_cred,$op['cred_montant']); $sum_deb=bcadd($sum_deb,$op['deb_montant']); + if ($idx%2 == 0) $class='class="odd"'; else $class=' class="even"'; + $idx++; - echo "". - "". + echo "". + "". td(h($op['jr_pj_number'])). "". "". diff --git a/include/class_follow_up.php b/include/class_follow_up.php index 6acafaa11..9c12735ec 100644 --- a/include/class_follow_up.php +++ b/include/class_follow_up.php @@ -138,7 +138,7 @@ class Follow_Up // Doc Type $doc_type=new ISelect(); $doc_type->name="dt_id"; - $doc_type->value=$this->db->make_array("select dt_id,dt_value from document_type"); + $doc_type->value=$this->db->make_array("select dt_id,dt_value from document_type order by dt_value"); $doc_type->selected=$this->dt_id; $doc_type->readonly=false; $str_doc_type=$doc_type->input(); @@ -152,7 +152,7 @@ class Follow_Up $str_doc_type=$doc_type->input().$this->db->get_value("select dt_value from document_type where dt_id=".$this->dt_id);*/ $doc_type=new ISelect(); $doc_type->name="dt_id"; - $doc_type->value=$this->db->make_array("select dt_id,dt_value from document_type"); + $doc_type->value=$this->db->make_array("select dt_id,dt_value from document_type order by dt_value"); $doc_type->selected=$this->dt_id; $doc_type->readonly=false; $str_doc_type=$doc_type->input(); @@ -914,8 +914,9 @@ class Follow_Up /*!\brief generate the document and add it to the action * \param md_id is the id of the document_modele + * \param $p_array contains normally the $_POST */ - function generate_document($md_id) + function generate_document($md_id,$p_array) { $doc=new Document($this->db); $mod=new Document_Modele($this->db,$md_id); @@ -923,7 +924,7 @@ class Follow_Up $doc->f_id=$this->f_id_dest; $doc->md_id=$md_id; $doc->ag_id=$this->ag_id; - $doc->Generate(); + $doc->Generate($p_array); } /*!\brief put an array in the variable member, the indice * is the member name diff --git a/include/class_lettering.php b/include/class_lettering.php index 6af91d242..7eb68a9f1 100644 --- a/include/class_lettering.php +++ b/include/class_lettering.php @@ -151,20 +151,20 @@ class Lettering if ( $first == 't') { // save into letter_deb - $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id1,$jl_id)); + if ($let1 == 0) $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id1,$jl_id)); } else { - $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id1,$jl_id)); + if ($let1 == 0)$lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id1,$jl_id)); } if ( $second == 't') { // save into letter_deb - $ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id2,$jl_id)); + if ($let2 == 0)$ld_id=$this->db->get_value('insert into letter_deb(j_id,jl_id) values($1,$2) returning ld_id',array($j_id2,$jl_id)); } else { - $lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id2,$jl_id)); + if ($let2 == 0)$lc_id=$this->db->get_value('insert into letter_cred(j_id,jl_id) values($1,$2) returning lc_id',array($j_id2,$jl_id)); } } @@ -515,17 +515,16 @@ class Lettering_Account extends Lettering ( select jl_id,coalesce(sum(j_montant),0) as cred_amount from letter_cred join jrnx using (j_id) group by jl_id) as CRED left join (select jl_id,coalesce(sum(j_montant),0) as deb_amount from letter_deb join jrnx using (j_id) group by jl_id) as DEB using (jl_id)) , letter_jl as (select jl_id,j_id from letter_cred union all select jl_id,j_id from letter_deb) - select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, + select distinct j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, let_diff.jl_id as letter, diff_letter1 as letter_diff from - jrnx join jrn on (j_grpt = jr_grpt_id) + jrnx join jrn on (j_grpt = jr_grpt_id) join letter_jl using (j_id) join let_diff using (jl_id) where j_poste = $1 and j_date >= to_date($2,'DD.MM.YYYY') and j_date <= to_date ($3,'DD.MM.YYYY') and $this->sql_ledger - and j_id in (select j_id from letter_deb join jnt_letter using (jl_id) union select j_id from letter_cred join jnt_letter using (jl_id) ) and diff_letter1 <> 0 order by j_date,j_id"; $this->content=$this->db->get_array($sql,array($this->account,$this->start,$this->end)); @@ -609,9 +608,9 @@ class Lettering_Card extends Lettering ( select jl_id,coalesce(sum(j_montant),0) as cred_amount from letter_cred join jrnx using (j_id) group by jl_id) as CRED left join (select jl_id,coalesce(sum(j_montant),0) as deb_amount from letter_deb join jrnx using (j_id) group by jl_id) as DEB using (jl_id)) , letter_jl as (select jl_id,j_id from letter_cred union all select jl_id,j_id from letter_deb) - select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, + select distinct j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, - let_diff.jl_id as letter, + coalesce(let_diff.jl_id,-1) as letter, diff_letter1 as letter_diff from jrnx join jrn on (j_grpt = jr_grpt_id) left join letter_jl using (j_id) @@ -635,7 +634,7 @@ class Lettering_Card extends Lettering ( select jl_id,coalesce(sum(j_montant),0) as cred_amount from letter_cred join jrnx using (j_id) group by jl_id) as CRED left join (select jl_id,coalesce(sum(j_montant),0) as deb_amount from letter_deb join jrnx using (j_id) group by jl_id) as DEB using (jl_id)) , letter_jl as (select jl_id,j_id from letter_cred union all select jl_id,j_id from letter_deb) - select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, + select DISTINCT j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, coalesce(let_diff.jl_id,-1) as letter, diff_letter1 as letter_diff @@ -680,7 +679,7 @@ class Lettering_Card extends Lettering ( select jl_id,coalesce(sum(j_montant),0) as cred_amount from letter_cred join jrnx using (j_id) group by jl_id) as CRED left join (select jl_id,coalesce(sum(j_montant),0) as deb_amount from letter_deb join jrnx using (j_id) group by jl_id) as DEB using (jl_id)) , letter_jl as (select jl_id,j_id from letter_cred union all select jl_id,j_id from letter_deb) - select j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, + select distinct j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,jr_pj_number, j_montant,j_debit,jr_comment,jr_internal,jr_id,jr_def_id, let_diff.jl_id as letter, diff_letter1 as letter_diff diff --git a/include/class_todo_list.php b/include/class_todo_list.php index 04e6d8d64..7dc91a769 100644 --- a/include/class_todo_list.php +++ b/include/class_todo_list.php @@ -112,8 +112,7 @@ class Todo_List { if ( isDate($this->tl_date) == false ) { - alert('Date est invalide'); - return 1; + $this->tl_date=date('d.m.Y'); } return 0; } @@ -129,7 +128,7 @@ class Todo_List { if ( $this->verify() != 0 ) return; if (trim($this->tl_title)=='') - $this->tl_title=substr(trim($this->tl_desc),0,40); + $this->tl_title=substr(trim($this->tl_desc),0,30); if (trim($this->tl_title)=='') { @@ -138,7 +137,7 @@ class Todo_List } /* limit the title to 35 char */ - $this->tl_title=substr(trim($this->tl_desc),0,40); + $this->tl_title=substr(trim($this->tl_title),0,30); $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login) ". " values (to_date($1,'DD.MM.YYYY'),$2,$3,$4) returning tl_id"; diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index 2ad8f09e6..1c325eb53 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -132,18 +132,19 @@ if (isset($_POST['record'])) { echo '

' . _('Attention numéro pièce existante, elle a du être adaptée') . '

'; } - if (isset($Ledger->doc)) - { - echo ''; - echo $Ledger->doc; - echo ''; - } /* Save the additional information into jrn_info */ $obj = new Acc_Ledger_Info($cn); $obj->save_extra($Ledger->jr_id, $_POST); printf('%s
', $jr_id, dossier::id(), $internal); // Feedback echo $Ledger->confirm($_POST, true); + if (isset($Ledger->doc)) + { + echo ''; + echo $Ledger->doc; + echo ''; + } + echo ''; exit(); } diff --git a/include/compta_fin_rec.inc.php b/include/compta_fin_rec.inc.php index 6ac427f97..479591e7d 100644 --- a/include/compta_fin_rec.inc.php +++ b/include/compta_fin_rec.inc.php @@ -117,7 +117,7 @@ echo 'solde Début' . $nstart_extrait->input(); echo 'solde Fin' . $nend_extrait->input(); echo IButton::tooggle_checkbox('rec1'); echo '

'; -echo HtmlInput::submit('save', 'Mettre à jour le n° de relevé banquaire'); +echo HtmlInput::submit('save', 'Mettre à jour le n° de relevé bancaire'); echo '
"._('Date').""._('n° pièce')." "._('Code interne')." "._('Description')." "._('Date').""._('n° pièce')." "._('Code interne')." "._('Description')." "._('Débit')." "._('Crédit')."
".format_date($op['j_date_fmt'])."
".smaller_date(format_date($op['j_date_fmt']))."".$vw_operation."".h($op['description'])."
'; $r = th('Date'); $r.=th('Libellé'); @@ -198,7 +198,7 @@ echo ''; echo '
'; -echo HtmlInput::submit('save', 'Mettre à jour le n° de relevé banquaire'); +echo HtmlInput::submit('save', 'Mettre à jour le n° de relevé bancaire'); echo ''; echo '
'; exit(); diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index cc2bc3ef4..121031bdc 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -151,7 +151,7 @@ global $g_parameter; printf ('%s
', $jr_id,dossier::id(),$internal); - echo $Ledger->confirm($_POST,true); + echo $Ledger->confirm($_POST,true); /* Show link for Invoice */ if (isset ($Ledger->doc) ) { diff --git a/include/constant.php b/include/constant.php index b12570681..d2c10a29f 100644 --- a/include/constant.php +++ b/include/constant.php @@ -35,17 +35,13 @@ $g_failed=""; $g_succeed=""; /*set to none for production */ /* uncomment for production */ -// $version_phpcompta=4620; -// define ("DEBUG",true); - - $version_phpcompta=SVNINFO; define ("DEBUG",false); -/* $version_phpcompta=4601; -define ("DEBUG",true); */ +//$version_phpcompta=4601; +//define ("DEBUG",true); -define ("DBVERSION",101); +define ("DBVERSION",102); define ("DBVERSIONREPO",14); define ('NOTFOUND','--not found--'); @@ -55,6 +51,7 @@ define ('MAX_ARTICLE',12); define ('MAX_CAT',15); define ('MAX_FORECAST_ITEM',10); define ('MAX_PREDEFINED_OPERATION',30); +define ('MAX_COMPTE_CARD',4); if ( DEBUG ) error_reporting(2147483647); else error_reporting(0); // Erreur diff --git a/include/template/form_ledger_fin.php b/include/template/form_ledger_fin.php index 677e86622..0d1417f85 100644 --- a/include/template/form_ledger_fin.php +++ b/include/template/form_ledger_fin.php @@ -21,7 +21,8 @@
- + + @@ -30,6 +31,7 @@ '; echo td($item['qcode'].$item['search']); +echo td($item['cname']); echo td($item['comment']); echo td($item['amount']); echo td($item['concerned']); diff --git a/include/template/ledger_detail_file.php b/include/template/ledger_detail_file.php index a21d9f834..4822910d6 100644 --- a/include/template/ledger_detail_file.php +++ b/include/template/ledger_detail_file.php @@ -1,11 +1,12 @@
- +
\ No newline at end of file diff --git a/include/template/ledger_detail_misc.php b/include/template/ledger_detail_misc.php index e37f1c9b9..bcd9aeb7e 100644 --- a/include/template/ledger_detail_misc.php +++ b/include/template/ledger_detail_misc.php @@ -99,6 +99,7 @@ echo th(_('Crédit'), 'style="text-align:right"'); echo Anc_Plan::hidden($a_anc); } echo ''; +$amount_idx=0; for ($e=0;$edet->array);$e++) { $row=''; $q=$obj->det->array; $view_history= sprintf('%s', @@ -151,13 +152,13 @@ echo ''; /* Analytic accountancy */ if ( $owner->MY_ANALYTIC != "nu" && $div=='popup'){ if ( preg_match('/^(6|7)/',$q[$e]['j_poste'])) { - -echo HtmlInput::hidden("amount_t".$e,$montant); + + echo HtmlInput::hidden("amount_t".$amount_idx,$q[$e]['j_montant']); $anc_op=new Anc_Operation($cn); $anc_op->j_id=$q[$e]['j_id']; echo HtmlInput::hidden('op[]',$anc_op->j_id); $row.=$anc_op->display_table(1,$q[$e]['j_montant'],$div); - + $amount_idx++; } else { $row.=td(''); } diff --git a/include/template/ledger_detail_ven.php b/include/template/ledger_detail_ven.php index ea3e287d6..c41d5985e 100644 --- a/include/template/ledger_detail_ven.php +++ b/include/template/ledger_detail_ven.php @@ -37,7 +37,7 @@ $bk=new Fiche($cn,$obj->det->array[0]['qs_client']); echo td(_('Client')); - $view_history= sprintf('%s', + $view_history= sprintf('%s', $bk->id, $gDossier, $bk->get_quick_code()); echo td(h($bk->getName())).td($view_history);; ?> diff --git a/include/template/letter_prop.php b/include/template/letter_prop.php index f1b252891..5997d7195 100644 --- a/include/template/letter_prop.php +++ b/include/template/letter_prop.php @@ -91,14 +91,14 @@ if ( $jnt_id == $this->content[$i]['letter'] && $i >= $linked_limit) continue; $check=new ICheckbox('ck[]',$this->content[$i]['j_id']); if ( $jnt_id == $this->content[$i]['letter'] && $i < $linked_limit) $check->selected=true; else $check->selected=false; -if ( $this->content[$i]['letter'] == -1 || $check->selected == true ) +if ( $this->content[$i]['letter'] < 0 || $check->selected == true ) echo $check->input(); echo HtmlInput::hidden('letter_j_id[]',$this->content[$i]['j_id']); ?> diff --git a/include/template/modele_document.php b/include/template/modele_document.php index a64195ba0..7a3400cf3 100644 --- a/include/template/modele_document.php +++ b/include/template/modele_document.php @@ -25,7 +25,7 @@ Catégorie de document $w=new ISelect(); $w->name="md_type"; - $w->value=$cn->make_array('select dt_id,dt_value from document_type'); + $w->value=$cn->make_array('select dt_id,dt_value from document_type order by dt_value'); $w->selected=$doc->md_type; echo $w->input(); ?>
codecode
content[$i]['letter']==-1)?" ":$this->content[$i]['letter']; +$letter=($this->content[$i]['letter']< 0)?" ":$this->content[$i]['letter']; ?>