diff --git a/contrib/comptabilite-francaise/copropriete/fr_plan_syndiccoprop.sql b/contrib/comptabilite-francaise/copropriete/fr_plan_syndiccoprop.sql new file mode 100644 index 000000000..0dd612dba --- /dev/null +++ b/contrib/comptabilite-francaise/copropriete/fr_plan_syndiccoprop.sql @@ -0,0 +1,133 @@ +-- +-- PostgreSQL database dump +-- Version 2008/02/10 09:19 +-- + +-- +-- Name: TABLE tmp_pcmn; Type: COMMENT; Schema: public; Owner: phpcompta +-- + +COMMENT ON TABLE tmp_pcmn IS 'Plan comptable - Syndicat des copropriétaires : strict'; + +-- +-- Data for Name: tmp_pcmn; Type: TABLE DATA; Schema: public; Owner: phpcompta +-- + +COPY tmp_pcmn (pcm_val, pcm_lib, pcm_val_parent) FROM stdin; +1 Classe 1 - Provisions, avances, subventions et emprunts 0 +10 Provisions et avances : 1 +102 Provisions pour travaux décidés 10 +103 Avances 10 +1031 Avances de trésorerie 103 +1032 Avances travaux au titre de l'article 18, 6e alinéa de la loi susvisée 103 +1033 Autres avances 103 +12 Solde en attente sur travaux et opérations exceptionnelles 1 +13 Subventions : 1 +131 Subventions accordées en instance de versement 13 +4 Classe 4 - Copropriétaires et tiers 0 +40 Fournisseurs : 4 +401 Factures parvenues 40 +408 Factures non parvenues 40 +409 Fournisseurs débiteurs 40 +42 Personnel : 4 +421 Rémunérations dues 42 +43 Sécurité sociale et autres organismes sociaux : 4 +431 Sécurité sociale 43 +432 Autres organismes sociaux 43 +44 Etat et collectivités territoriales : 4 +441 Etat et autres organismes - subventions à recevoir 44 +442 Etat - impôts et versements assimilés 44 +443 Collectivités territoriales - aides 44 +45 Collectivité des copropriétaires : 4 +450 Copropriétaire individualisé 45 +4501 Sur décision AG : Copropriétaire - budget prévisionnel 450 +4502 Sur décision AG : Copropriétaire - travaux de l'article 14-2 de la loi susvisée et opérations exceptionnelles 450 +4503 Sur décision AG : Copropriétaire - avances 450 +4504 Sur décision AG : Copropriétaire - emprunts 450 +459 Copropriétaire - créances douteuses 45 +46 Débiteurs et créditeurs divers : 4 +461 Débiteurs divers 46 +462 Créditeurs divers 46 +47 Compte d'attente : 4 +471 Compte en attente d'imputation débiteur 47 +472 Compte en attente d'imputation créditeur 47 +48 Compte de régularisation : 4 +486 Charges payées d'avance 48 +487 Produits encaissés d'avance 48 +49 Dépréciation des comptes de tiers : 4 +491 Copropriétaires 49 +492 Personnes autres que les copropriétaires 49 +5 Classe 5 - Comptes financiers 0 +50 Fonds placés : 5 +501 Compte à terme 50 +502 Autre compte 50 +51 Banques, ou fonds disponibles en banque pour le syndicat : 5 +512 Banques 51 +514 Chèques postaux 51 +53 Caisse. 5 +6 Classe 6 - Comptes de charges 0 +60 Achats de matières et fournitures : 6 +601 Eau 60 +602 Electricié 60 +603 Chauffage, énergie et combustibles 60 +604 Achats produits d'entretien et petits équipements 60 +605 Matériel 60 +606 Fournitures 60 +61 Services extérieurs : 6 +611 Nettoyage des locaux 5 +612 Locations immobiliéres 61 +613 Locations mobiliéres 61 +614 Contrats de maintenance 61 +615 Entretien et petites réparations 61 +616 Primes d'assurances 61 +62 Frais d'administration et honoraires : 6 +621 Rémunérations du syndic sur gestion copropriété 62 +6211 Rémunération du syndic 621 +6212 Débours 621 +6213 Frais postaux 621 +622 Autres honoraires du syndic 62 +6221 Honoraires travaux 622 +6222 Prestations particulières 622 +6223 Autres honoraires 622 +623 Rémunérations de tiers intervenants 62 +624 Frais du conseil syndical 62 +63 Impôts - taxes et versements assimilés : 6 +632 Taxe de balayage 63 +633 Taxe foncière 63 +634 Autres impôts et taxes 63 +64 Frais de personnel : 6 +641 Salaires 64 +642 Charges sociales et organismes sociaux 64 +643 Taxe sur les salaires 64 +644 Autres (médecine du travail, mutuelles, etc.) 64 +66 Charges financières des emprunts, agios ou autres : 6 +661 Remboursement d'annuités d'emprunt 66 +662 Autres charges financières et agios 66 +67 Charges pour travaux et opérations exceptionnelles : 6 +671 Travaux décidés par l'assemblée générale 67 +672 Travaux urgents 67 +673 Etudes techniques, diagnostic, consultation 67 +677 Pertes sur créances irrécouvrables 67 +678 Charges exceptionnelles 67 +68 Dotations aux dépréciations sur créances douteuses. 6 +7 Classe 7 - Comptes de produits 0 +70 Appels de fonds : 7 +701 Provisions sur opérations courantes 70 +702 Provisions sur travaux de l'article 14-2 et opérations exceptionnelles 70 +703 Avances 70 +704 Remboursements d'annuités d'emprunts 70 +71 Autres produits : 7 +711 Subventions 71 +712 Emprunts 71 +713 Indemnités d'assurances 71 +714 Produits divers (dont intérêts légaux dus par les copropriétaires) 71 +716 Produits financiers 71 +718 Produits exceptionnels 71 +78 Reprises de dépréciations sur créances douteuses. 7 +8 Comptes spéciaux 0 +9 Comptes analytique 0 +\. + +-- +-- PostgreSQL database dump complete +-- diff --git a/contrib/document_test/facture.odt b/contrib/document_test/facture.odt index 0132a5e63..460a0f33d 100644 Binary files a/contrib/document_test/facture.odt and b/contrib/document_test/facture.odt differ diff --git a/html/admin/setup.php b/html/admin/setup.php index caedcc798..ca5a0ce65 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -147,7 +147,7 @@ function ExecuteScript($p_cn,$script) { echo_debug('setup.php',__LINE__,"Execute sql $sql"); if ( ExecSql($p_cn,$sql,false) == false ) { Rollback($p_cn); - if ( DEBUG=='false' ) ob_clean(); + if ( DEBUG=='false' ) ob_end_clean(); print "ERROR : $sql"; exit(); } @@ -156,7 +156,7 @@ echo_debug('setup.php',__LINE__,"Execute sql $sql"); print "
Il est conseillé de ne PAS utiliser Internet Explorer. -
- Vous pouvez utiliser un autre browser: firefox, mozilla, netscape, Konqueror, opera... -
-- - Si vous avez envie de nous rejoindre, vous êtes les bienvenus - . -
-
| CE | "; foreach( $per as $c) { @@ -401,7 +403,8 @@ Array $r.=''; $r.=' |
|---|---|
| '.$key.' | '; diff --git a/include/class_bud_synthese_hypo.php b/include/class_bud_synthese_hypo.php index 1075676ee..f6b6c038e 100644 --- a/include/class_bud_synthese_hypo.php +++ b/include/class_bud_synthese_hypo.php @@ -87,7 +87,7 @@ Array [GROUPE1] => 81.7 [GROUPE3] => 28 [total_row] => 109.7 - [acc_name] => Electricité + [acc_name] => Electricite [acc_amount] => 0 ) diff --git a/include/class_customer.php b/include/class_customer.php index ac69ffaa2..9f23b0653 100644 --- a/include/class_customer.php +++ b/include/class_customer.php @@ -105,8 +105,8 @@ class Customer extends fiche{ jrnx as A join jrnx as B using (j_grpt) where - A.j_poste like '".$CUSTOMER."%' and - B.j_poste like '".$SOLD."%' + A.j_poste::text like '".$CUSTOMER."%' and + B.j_poste::text like '".$SOLD."%' $cond_sql "; diff --git a/include/class_document.php b/include/class_document.php index 427e93cd0..06da2fcd8 100644 --- a/include/class_document.php +++ b/include/class_document.php @@ -464,6 +464,9 @@ class Document * - [MY_TVA] * - [MY_STREET] * - [MY_NUMBER] + * - BON_COMMANDE + * - OTHER_INFO + * - CUST_NUM * * \param TAG * \return String which must replace the tag @@ -554,8 +557,7 @@ class Document case 'CUST_CP': $tiers=new fiche($this->db); -$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ -'e_client']; + $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_CP); @@ -563,8 +565,7 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ case 'CUST_CITY': $tiers=new fiche($this->db); -$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ -'e_client']; + $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_CITY); @@ -573,8 +574,7 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ case 'CUST_CO': $tiers=new fiche($this->db); -$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ -'e_client']; + $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['e_client']; $tiers->get_by_qcode($qcode,false); $r=$tiers->strAttribut(ATTR_DEF_PAYS); @@ -584,11 +584,17 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ case 'CUST_VAT': $tiers=new fiche($this->db); -$qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ -'e_client']; + $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST['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']; + $tiers->get_by_qcode($qcode,false); + $r=$tiers->strAttribut(ATTR_DEF_NUMBER_CUSTOMER); + break; + // Marchandise in $_POST['e_march*'] // \see user_form_achat.php or user_form_ven.php case 'NUMBER': @@ -811,6 +817,19 @@ $qcode=isset($_REQUEST['qcode_dest'])?$_REQUEST['qcode_dest']:$_REQUEST[ $r=$sum; break; + case 'BON_COMMANDE': + if ( isset($_REQUEST['bon_comm'])) + return $_REQUEST['bon_comm']; + else + return ""; + break; + case 'OTHER_INFO': + if ( isset($_REQUEST['other_info'])) + return $_REQUEST['other_info']; + else + return ""; + break; + } return $r; diff --git a/include/class_dossier.php b/include/class_dossier.php index cd32a3894..3ad92d9bf 100644 --- a/include/class_dossier.php +++ b/include/class_dossier.php @@ -37,6 +37,7 @@ require_once('ac_common.php'); class dossier { + /*!\brief return the $_REQUEST['gDossier'] after a check */ static function id() { echo_debug(__FILE__,__LINE__,"id"); diff --git a/include/class_fiche.php b/include/class_fiche.php index d05171cbb..15e1e15f9 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -431,9 +431,13 @@ class fiche { * \brief insert a new record * * \param p_fiche_def fiche_def.fd_id + * \param p_array is the array containing the data */ - function insert($p_fiche_def) + function insert($p_fiche_def,$p_array=null) { + if ( $p_array == null) + $p_array=$_POST; + $fiche_id=NextSequence($this->cn,'s_fiche'); $this->id=$fiche_id; // first we create the card @@ -444,8 +448,8 @@ class fiche { " values (%d,%d)", $fiche_id,$p_fiche_def); $Ret=ExecSql($this->cn,$sql); - // parse the $_POST array - foreach ($_POST as $name=>$value ) + // parse the $p_array array + foreach ($p_array as $name=>$value ) { echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ; list ($id) = sscanf ($name,"av_text%d"); @@ -471,8 +475,8 @@ class fiche { $exercice=$user->get_exercice(); if ( $exercice == 0 ) throw Exception ('Annee invalide erreur'); - $str_stock=sprintf('insert into stock_goods(f_id,sg_initial,sg_code,sg_type,sg_exercice) '. - ' values (%d,upper(\'%s\'),\'c\',\'%s\')', + $str_stock=sprintf('insert into stock_goods(f_id,sg_quantity,sg_comment,sg_code,sg_type,sg_exercice) '. + ' values (%d,0,\'%s\',upper(\'%s\'),\'d\',\'%s\')', $fiche_id, 'initial', FormatString($value), @@ -565,12 +569,15 @@ class fiche { /*!\brief update a card * \todo add a check to return an error and rollback operation */ - function update() + function update($p_array=null) { + if ( $p_array == null) + $p_array=$_POST; + try { StartSql($this->cn); - // parse the $_POST array - foreach ($_POST as $name=>$value ) + // parse the $p_array array + foreach ($p_array as $name=>$value ) { echo_debug ("class_fiche",__LINE__,"Name = $name value $value") ; list ($id) = sscanf ($name,"av_text%d"); @@ -619,19 +626,24 @@ class fiche { } if ( $id == ATTR_DEF_STOCK ) { $st=CountSql($this->cn,'select * from stock_goods where '. - " upper(sg_code)=upper('$value')"); + " f_id=".$this->id); if ( $st == 0 ) { $user=new User($this->cn); $exercice=$user->get_exercice(); if ( $exercice == 0 ) throw Exception ('Annee invalide erreur'); - $str_stock=sprintf('insert into stock_goods(f_id,sg_comment,sg_code,sg_type,sg_exercice) '. - ' values (%d,upper(\'%s\'),upper(\'%s\'),\'d\',%s)', - $this->id, - 'initial', - FormatString($value), - $exercice); - + $str_stock=sprintf('insert into stock_goods(f_id,sg_quantity,sg_comment,sg_code,sg_type,sg_exercice) '. + ' values (%d,0,\'%s\',upper(\'%s\'),\'d\',\'%s\')', + $this->id, + 'initial', + FormatString($value), + $exercice); + + ExecSql($this->cn,$str_stock); + }else { + $str_stock=sprintf("update stock_goods set sg_code=upper('%s') where f_id=%d", + FormatString($value), + $this->id); ExecSql($this->cn,$str_stock); } } @@ -876,12 +888,15 @@ class fiche { * * \return none */ - function HtmlTable() + function HtmlTable($p_array=null) { + if ( $p_array == null) + $p_array=$_POST; + $name=$this->getName(); - list($array,$tot_deb,$tot_cred)=$this->get_row( $_POST['from_periode'], - $_POST['to_periode'] + list($array,$tot_deb,$tot_cred)=$this->get_row( $p_array['from_periode'], + $p_array['to_periode'] ); if ( count($this->row ) == 0 ) @@ -928,8 +943,11 @@ class fiche { * * \return none */ - function HtmlTableHeader() + function HtmlTableHeader($p_array=null) { + if ( $p_array == null) + $p_array=$_POST; + $submit=new widget(); $hid=new widget("hidden"); echo '
| $image_ascEch $sql_fin="("; $or=""; foreach ($a_parm_code as $code) { - $sql_fin.="$or j_poste like '".$code['p_value']."%'"; + $sql_fin.="$or j_poste::text like '".$code['p_value']."%'"; $or=" or "; } $sql_fin.=")"; @@ -545,7 +569,7 @@ $sort_echeance=" | $image_ascEch $l_poste=FormatString($l_poste); if ( $l_poste != null ) { $sql.=$l_and." jr_grpt_id in (select j_grpt - from jrnx where j_poste like '$l_poste' ) "; + from jrnx where j_poste::text like '$l_poste' ) "; $l_and=" and "; } // Quick Code @@ -729,10 +753,11 @@ $sort_echeance=" | $image_ascEch
if ( $row['jr_pj_name'] != "")
{
$image=' ';
- $r.=" | ".sprintf('%s', + $r.=" | ".sprintf('%s', $p_jrn, $row['jr_grpt_id'], - $str_dossier, + $str_dossier, + $_REQUEST['PHPSESSID'], $image) ." | "; } diff --git a/include/user_form_ach.php b/include/user_form_ach.php index 0b11a47be..4c5533627 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -492,7 +492,7 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) $per->set_jrn($p_jrn); $per->set_periode($p_periode); - // Periode fermé + // Periode ferme if ( $per->is_open() == 0) { $msg="Cette periode est fermee pour ce journal"; @@ -833,6 +833,8 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $aNd_amount[$i]=0.0; $aTva_ded_impot[$i]=0.0; $aTva_ded_impot_recup[$i]=0.0; + $aDep_priv[$i]=0.0; + $poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT); @@ -840,26 +842,51 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) if ( $a_price[$i]*$a_quant[$i] == 0 ) continue; $amount=$a_price[$i]*$a_quant[$i]; - //We don't compute vat if it's given - $lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i], $a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i]; - + //We don't compute vat if it's given + $lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i], $a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i]; + //---------------------------------------------------------------------- // Put the non deductible part into a special account $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEPENSE_NON_DEDUCTIBLE); echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu"); if ( $non_dedu != null && strlen(trim($non_dedu)) != 0) - { - // if vat if given we use it to compute ND - $nd_amount=($a_vat_amount[$i]==0)?round($a_quant[$i]*$a_price[$i]*$non_dedu,2):round($a_vat_amount*$non_dedu,2); - - // save it - echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);"); - $dna=new parm_code($p_cn,'DNA'); - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); - $amount=$amount-$nd_amount; - - // save the ND in an array (for the easy view) - $aNd_amount[$i]=$nd_amount; - } + { + // this doens't concern the vat + $nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2); + // save it + echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);"); + $dna=new parm_code($p_cn,'DNA'); + $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); + $amount=$amount-$nd_amount; + + // save the ND in an array (for the easy view) + $aNd_amount[$i]=$nd_amount; + } + //---------------------------------------------------------------------- + // Put the non deductible part into a special account + $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEP_PRIV); + echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu"); + if ( $non_dedu != null && strlen(trim($non_dedu)) != 0) + { + // Remove also the vat + $nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2); + $tva_nd=round($lvat*$non_dedu,2); + $nd_amount+=$tva_nd; + + // save it + $dna=new parm_code($p_cn,'DEP_PRIV'); + $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); + + // modify sum + $amount=$amount-$nd_amount+$tva_nd; + $lvat-=$tva_nd; + + $sum_tva_nd+=$tva_nd; + + // save the ND in an array (for the easy view) + $aDep_priv[$i]=$nd_amount; + } + + //---------------------------------------------------------------------- // Put the non deductible part into a special account $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE); echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu"); @@ -877,27 +904,27 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_dna->p_value,$e_date,round($ded_vat,2),$seq,$periode); } - + //---------------------------------------------------------------------- // Put the non deductible part into a special account $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP); echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu"); if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 ) - { - - $ded_vat=($lvat != null )?$lvat*$non_dedu:0; - - $sum_tva_nd+=round($ded_vat,2); - $aTva_ded_impot_recup[$i]=round($ded_vat,2); - - // Save it - $tva_ded_impot=new parm_code($p_cn,'TVA_DED_IMPOT'); - echo_debug('user_form_ach.php',__LINE__, - "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); - - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode); - } + { + $ded_vat=($lvat != null )?$lvat*$non_dedu:0; + + $sum_tva_nd+=round($ded_vat,2); + $aTva_ded_impot_recup[$i]=round($ded_vat,2); + + // Save it + $tva_ded_impot=new parm_code($p_cn,'TVA_DED_IMPOT'); + echo_debug('user_form_ach.php',__LINE__, + "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); + + $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode); + } + //---------------------------------------------------------------------- @@ -905,7 +932,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode);"); $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode,$a_good[$i]); - /* \brief if the quantity is < 0 then the stock increase (return of + /*! \brief if the quantity is < 0 then the stock increase (return of * material) */ $nNeg=($a_quant[$i]<0)?-1:1; @@ -924,53 +951,56 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $op->oa_description=$comm; $op->save_form_plan($_POST,$i); } - //--------------------------------------------------------- - // insert into quant_purchase - //--------------------------------------------------------- - - echo_debug(__FILE__.":".__LINE__,"a_vat = ",$a_vat); - // echo_debug(__FILE__.":".__LINE__."a_vat[$i] =",$a_vat[$i]); - //!\note - // $a_vat_good[$i] contains the tva_id - // $a_vat_amount[$i] contains the amount of vat - $vat_code=$a_vat_good[$i]; - $computed_vat=$lvat-$aNd_amount[$i]-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i]; - $qp_vat=($vat_code==-1)?0:$computed_vat; - - echo_debug('form_ach',__LINE__,"Insert into insert_quant_purchase"); - $r=ExecSql($p_cn,"select insert_quant_purchase ". - "('".$internal."'". - ",".$j_id. - ",'".$a_good[$i]."'". - ",".$a_quant[$i].",". - round($amount,2). - ",".$qp_vat. - ",".$vat_code. - ",".$aNd_amount[$i]. - ",".$aTva_ded_impot[$i]. - ",".$aTva_ded_impot_recup[$i]. - ",'".$e_client."')"); - - + //--------------------------------------------------------- + // insert into quant_purchase + //--------------------------------------------------------- + + echo_debug(__FILE__.":".__LINE__,"a_vat = ",$a_vat); + // echo_debug(__FILE__.":".__LINE__."a_vat[$i] =",$a_vat[$i]); + //!\note + // $a_vat_good[$i] contains the tva_id + // $a_vat_amount[$i] contains the amount of vat + $vat_code=$a_vat_good[$i]; + // $computed_vat=$lvat-$aNd_amount[$i]-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i]; + $computed_vat=$lvat-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i]; + $qp_vat=($vat_code==-1)?0:$computed_vat; + + echo_debug('form_ach',__LINE__,"Insert into insert_quant_purchase"); + $r=ExecSql($p_cn,"select insert_quant_purchase ". + "('".$internal."'". + ",".$j_id. + ",'".$a_good[$i]."'". + ",".$a_quant[$i].",". + round($amount,2). + ",".$qp_vat. + ",".$vat_code. + ",".$aNd_amount[$i]. + ",".$aTva_ded_impot[$i]. + ",".$aTva_ded_impot_recup[$i]. + ",".$aDep_priv[$i]. + ",'".$e_client."')"); + + } // end loop - - // set up internal code for quant_purchase - + + // set up internal code for quant_purchase + // Insert Vat $sum_tva=0.0; if ( $a_vat != null ) // no vat { - echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true)); - foreach ($a_vat as $tva_id => $e_tva_amount ) - { - echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id"); - $poste=GetTvaPoste($p_cn,$tva_id,'d'); - if ($e_tva_amount == 0 ) continue; - echo_debug('user_form_ach',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode);"); - $r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode); - $sum_tva+=round($e_tva_amount,2); - } + echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true)); + foreach ($a_vat as $tva_id => $e_tva_amount ) + { + echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id"); + if ($e_tva_amount == 0 ) continue; + + $poste=GetTvaPoste($p_cn,$tva_id,'d'); + + $r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode); + $sum_tva+=round($e_tva_amount,2); + } } echo_debug('user_form_ach.php',__LINE__,"echeance = $e_ech"); echo_debug('user_form_ach.php',__LINE__,"sum_tva = $sum_tva"); @@ -984,14 +1014,14 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($amount_jrn+$sum_tva+$sum_tva_nd,2),$seq, $periode,$e_client); - + $r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"--",$seq,$periode); // Set Internal code and Comment - $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". + $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". " jr_grpt_id = ".$seq); - + $comment=(FormatString($e_comm) == null )?$internal." Fournisseur : ".GetFicheName($p_cn,$e_client):FormatString($e_comm); // Update and set the invoice's comment @@ -999,14 +1029,14 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) if ( isset ($_FILES)) save_upload_document($p_cn,$seq); - // Save the operation - if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){ - echo_debug(__FILE__.':'.__LINE__.'- ','save opd'); - $opd=new Pre_op_ach($p_cn); - $opd->get_post(); - $opd->save(); + // Save the operation + if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){ + echo_debug(__FILE__.':'.__LINE__.'- ','save opd'); + $opd=new Pre_op_ach($p_cn); + $opd->get_post(); + $opd->save(); echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd); - } + } } catch (Exception $e) { echo ''. 'Erreur dans l\'enregistrement '. diff --git a/include/user_form_ven.php b/include/user_form_ven.php index d7bc0297c..ed9cc17d4 100644 --- a/include/user_form_ven.php +++ b/include/user_form_ven.php @@ -235,7 +235,7 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_ $Quantity->size=9; //$r.=InputType("","TEXT","e_quant".$i,$quant,$pview_only); $r.=$Quantity->IOValue("e_quant".$i,$quant); - + $r.=""; } @@ -336,8 +336,8 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) // compare hidden value and computed if ( round($ca_amount-$hidden_amount,2) != 0 ) { - $msg="Montant CA est différent total marchandise"; - $msg.="montant encodé $ca_amount marchandise $hidden_amount"; + $msg="Montant CA est different total marchandise"; + $msg.="montant encode $ca_amount marchandise $hidden_amount"; echo ""; return null; @@ -644,15 +644,19 @@ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form' if ( CountSql($p_cn, "select md_id,md_name from document_modele where md_type=4") > 0 ) { - $r.='Générer une facture '; - // We propose to generate the invoice and some template - $doc_gen=new widget("select"); - $doc_gen->name="gen_doc"; - $doc_gen->value=make_array($p_cn, - "select md_id,md_name from document_modele where md_type=4"); - $r.=$doc_gen->IOValue(); - - $r.="
|---|
| '; + $r.= ''. + 'Recheche | '; + foreach($amodule as $col ) { + $url="control.php?".dossier::get()."&m=".$col['value']; + if ( $p_from==$col['value']) { + $r.= ''. + ''.$col['label'].''. + ' | '; + + } else { + $r.= ''. + ''.$col['label'].''. + ' | '; + } + + } + $r.='