diff --git a/html/show_tva.php b/html/show_tva.php index aed984ee2..9be7a10fc 100644 --- a/html/show_tva.php +++ b/html/show_tva.php @@ -36,9 +36,9 @@ html_min_page_start($User->theme,"onLoad='window.focus();'"); ?> = to_date('$p_from','DD.MM.YYYY') and p_end <= to_date('$p_to','DD.MM.YYYY')) "; - return $periode; } diff --git a/include/action.common.inc.php b/include/action.common.inc.php index e25ea6ea6..2cbf1732a 100644 --- a/include/action.common.inc.php +++ b/include/action.common.inc.php @@ -266,6 +266,17 @@ function ShowActionList($cn,$p_base) printf (_('Titre ou référence').': ', $a); echo '
'; + + /* type of documents */ + $type_doc=new ISelect ('tdoc'); + $aTDoc=$cn->make_array('select dt_id,dt_value from document_type'); + $aTDoc[]=array('value'=>'-1','label'=>_('Tous les types')); + $type_doc->value=$aTDoc; + $type_doc->selected=(isset ($_GET['tdoc']))?$_GET['tdoc']:-1; + echo 'Type de document'; + echo $type_doc->input(); + echo '
'; + $see_all=new ICheckBox('see_all'); $see_all->selected= (isset($_REQUEST['see_all']))?true:false; echo _('les actions fermées aussi:').$see_all->input().'
'; @@ -298,7 +309,9 @@ function ShowActionList($cn,$p_base) if ( (isset($_GET['qcode']) && trim($_GET['qcode']) != '') || (isset($_GET['query']) && trim($_GET['query']) != '') || isset ($_GET['all_action']) || - isset ($_GET['see_all'])) { + isset ($_GET['see_all']) || + (isset ($_GET['tdoc']) && trim($_GET['tdoc']) !='-1')) + { /* nothing */ } else { ?> @@ -353,6 +366,9 @@ function ShowActionList($cn,$p_base) $str=" and (f_id_dest= ".$fiche->id." ) "; } } + if (isset($_GET['tdoc']) && $_GET['tdoc'] != -1 ){ + $query .= ' and dt_id = '.Formatstring($_GET['tdoc']); + } if ( ! isset($_REQUEST['see_all'])) $query .= ' and ag_state in (2,3) '; if ( ! isset($_REQUEST['all_action'])) $query .= " and (ag_owner='".$_SESSION['g_user']."' or ag_dest='".$_SESSION['g_user']."')"; $r=$act->myList($p_base,ACTION,$query.$str); diff --git a/include/action.inc.php b/include/action.inc.php index 396f2d3ec..693f7c201 100644 --- a/include/action.inc.php +++ b/include/action.inc.php @@ -39,7 +39,7 @@ $search_card->title=_('Recherche de fiche'); $search_card->value=''; echo $search_card->input(); echo ICard::ipopup('ipopcard'); - +echo ICard::ipopup('ipop_newcard'); $retour=HtmlInput::button_anchor(_('Retour'),'?p_action=suivi_courrier&my_action&'.dossier::get()); //----------------------------------------------------- diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php index 08568405b..b5b8d5846 100644 --- a/include/class_acc_account_ledger.php +++ b/include/class_acc_account_ledger.php @@ -209,6 +209,7 @@ function get_solde_detail($p_cond="") { $Res=$this->db->exec_sql($sql); $Max=Database::num_row($Res); + if ($Max==0) { return array('debit'=>0, 'credit'=>0, diff --git a/include/class_acc_ledger_info.php b/include/class_acc_ledger_info.php index e34d6fb41..1190c8cb6 100644 --- a/include/class_acc_ledger_info.php +++ b/include/class_acc_ledger_info.php @@ -144,6 +144,26 @@ class Acc_Ledger_Info { return $this->jr_id; } } + /** + *@brief save all extra information in once, called by compta_ven and compta_ach + *@param $p_jr_id is the jrn.jr_id concerned, + *@param $p_array is the array with the data usually it is $_POST + *@note will change this->jr_id + *@see compta_ven.inc.php compta_ach.inc.php + */ + function save_extra($p_jr_id,$p_array) { + $this->jr_id=$p_jr_id; + if (strlen(trim($p_array['bon_comm'] )) != 0 ) { + $this->set_type('BON_COMMANDE'); + $this->set_value($p_array['bon_comm']); + $this->insert(); + } + if (strlen(trim($p_array['other_info'] )) != 0 ) { + $this->set_type('OTHER'); + $this->set_value($p_array['other_info']); + $this->insert(); + } + } static function test_me() { echo "Dossier = ".Dossier::id(); $cn=new Database(Dossier::id()); diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index 7dfba7c29..52725bafe 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -160,6 +160,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger { } /*!\brief insert into the database, it calls first the verify function + * change the value of this->jr_id and this->jr_internal *\param $p_array is usually $_POST or a predefined operation *\return string *\note throw an Exception @@ -172,7 +173,10 @@ class Acc_Ledger_Purchase extends Acc_Ledger { $group=$this->db->get_next_seq("s_oa_group"); /* for analytic */ $seq=$this->db->get_next_seq('s_grpt'); $this->id=$p_jrn; + $internal=$this->compute_internal_code($seq); + $this->internal=$internal; + $cust=new fiche($this->db); $cust->get_by_qcode($e_client); $poste=$cust->strAttribut(ATTR_DEF_ACCOUNT); @@ -448,7 +452,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger { $acc_operation->periode=$tperiode; $acc_operation->pj=$e_pj; $acc_operation->mt=$mt; - $acc_operation->insert_jrn(); + $this->jr_id=$acc_operation->insert_jrn(); $this->pj=$acc_operation->set_pj(); // Set Internal code @@ -1115,11 +1119,17 @@ class Acc_Ledger_Purchase extends Acc_Ledger { } // check for upload piece - $file=new IFile(); +/** +*@todo clean dead code +*/ + /* $file=new IFile(); $file->table=0; $r.=_("Ajoutez une pièce justificative "); $r.=$file->input("pj",""); + */ $r.=HtmlInput::warnbulle(12); + $r.=$this->extra_info(); + /* Propose to generate a note of fee */ if ( $this->db->count_sql("select md_id,md_name from document_modele where md_type=10") > 0 && $e_mp != 0) @@ -1138,6 +1148,45 @@ class Acc_Ledger_Purchase extends Acc_Ledger { return $r; } + /*!\brief the function extra info allows to + * - add a attachment + * - generate an invoice + * - insert extra info + *\return string + */ + public function extra_info() { + $r=""; + $r.='
'; + $r.='
'._('Document à générer').''; + // check for upload piece + $file=new IFile(); + $file->table=0; + $r.=_("Ajoutez une pièce justificative "); + $r.=$file->input("pj",""); + + if ( $this->db->count_sql("select md_id,md_name from document_modele where md_type=4") > 0 ) + { + + + $r.=_('ou générer un document').' '; + // We propose to generate the note of fee + $doc_gen=new ISelect(); + $doc_gen->name="gen_doc"; + $doc_gen->value=$this->db->make_array( + "select md_id,md_name ". + " from document_modele where md_type=4"); + $r.=$doc_gen->input().'
'; + } + $r.='
'; + $obj=new IText(); + $r.=_('Numero de bon de commande : ').$obj->input('bon_comm').'
'; + $r.=_('Autre information : ').$obj->input('other_info').'
'; + + $r.="
"; + $r.='
'; + return $r; + } + /*!\brief update the payment */ diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index 4e66dd4de..f70143387 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -160,7 +160,8 @@ class Acc_Ledger_Sold extends Acc_Ledger { echo "

Acc_Ledger_Sold::save Not implemented

"; } - /*!\brief insert into the database, it calls first the verify function + /*!\brief insert into the database, it calls first the verify function, + * change the value of this->jr_id and this->jr_internal *\param $p_array is usually $_POST or a predefined operation *\return string *\note throw an Exception @@ -174,6 +175,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $seq=$this->db->get_next_seq('s_grpt'); $this->id=$p_jrn; $internal=$this->compute_internal_code($seq); + $this->internal=$internal; $oPeriode=new Periode($this->db); $check_periode=$this->check_periode(); @@ -331,7 +333,7 @@ class Acc_Ledger_Sold extends Acc_Ledger { $acc_operation->pj=$e_pj; $acc_operation->mt=$mt; - $acc_operation->insert_jrn(); + $this->jr_id=$acc_operation->insert_jrn(); $this->pj=$acc_operation->set_pj(); diff --git a/include/class_action.php b/include/class_action.php index cb4ebf8c6..8d55b23a1 100644 --- a/include/class_action.php +++ b/include/class_action.php @@ -255,6 +255,16 @@ class Action $ag_ref->value=FormatString($this->ag_ref); $client_label=new ISpan(); + /* Add button */ + $f_add_button=new IButton('add_card'); + $f_add_button->label=_('Créer une nouvelle fiche'); + $f_add_button->set_attribute('ipopup','ipop_newcard'); + $filter=$this->db->make_list('select fd_id from fiche_def '); + $f_add_button->set_attribute('filter',$filter); + + $f_add_button->javascript=" select_card_type(this);"; + $str_add_button=$f_add_button->input(); + // f_id_dest sender if ( $this->qcode_dest != '- ERROR -' && strlen(trim($this->qcode_dest)) != 0) { diff --git a/include/class_itva.php b/include/class_itva.php index 212cabfe0..a2bea38db 100644 --- a/include/class_itva.php +++ b/include/class_itva.php @@ -34,7 +34,8 @@ require_once('class_html_input.php'); if ( $this->readOnly==true) return $this->display(); $r=sprintf('Tva ', + ' ID="%s" NAME="%s" VALUE="%s" SIZE="3" onChange="ChangeTVA(\'%s\',\'%s\');">', + $this->name, $this->name, $this->value, $this->label, diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index 5e80af41c..1f85f876d 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -55,7 +55,9 @@ $str_dossier=dossier::get(); $array=array( array('?p_action=ach&sa=n&'.$str_dossier,_('Nouvelle dépense'),_('Nouvel achat ou dépense'),1), array('?p_action=ach&sa=l&'.$str_dossier,_('Liste achat'),_('Liste des achats'),2), - array('?p_action=ach&sa=lnp&'.$str_dossier,_('Liste dépenses non payées'),_('Liste des ventes non payées'),3) + array('?p_action=ach&sa=lnp&'.$str_dossier,_('Liste dépenses non payées'),_('Liste des ventes non payées'),3), + array('commercial.php?p_action=supplier&'.$str_dossier,_('Fournisseurs'),_('Fournisseurs')), + array('?p_action=impress&type=jrn&'.$str_dossier,_('Impression'),_('Impression')) ); $sa=(isset ($_REQUEST['sa']))?$_REQUEST['sa']:-1; @@ -164,6 +166,10 @@ if ( $def==1 || $def == 4 ) { if (isset($Ledger->doc)) { echo $Ledger->doc.'
'; } + /* Save the additional information into jrn_info */ + $obj=new Acc_Ledger_Info($cn); + $obj->save_extra($Ledger->jr_id,$_POST); + echo HtmlInput::button_anchor(_('Nouvelle dépense'),$href.'?p_action=ach&sa=n&'.dossier::get()); echo ''; exit(); diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index 2f96f99ec..e2e25d358 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -54,7 +54,9 @@ $str_dossier=dossier::get(); $array=array( array('?p_action=ven&sa=n&'.$str_dossier,_('Nouvelle vente'),_('Nouvelle vente'),1), array('?p_action=ven&sa=l&'.$str_dossier,_('Liste ventes'),_('Liste des ventes'),2), - array('?p_action=ven&sa=lnp&'.$str_dossier,_('Liste vente non payées'),_('Liste des ventes non payées'),3) + array('?p_action=ven&sa=lnp&'.$str_dossier,_('Liste vente non payées'),_('Liste des ventes non payées'),3), + array('commercial.php?p_action=client&'.$str_dossier,_('Clients'),_('Clients')), + array('?p_action=impress&type=jrn&'.$str_dossier,_('Impression'),_('Impression')) ); $sa=(isset ($_REQUEST['sa']))?$_REQUEST['sa']:-1; @@ -175,17 +177,8 @@ if ( $def==1 || $def == 4 ) { /* Save the additional information into jrn_info */ $obj=new Acc_Ledger_Info($cn); - $jr_id=$obj->search_id_internal($internal); - if (strlen(trim($_POST['bon_comm'] )) != 0 ) { - $obj->set_type('BON_COMMANDE'); - $obj->set_value($_POST['bon_comm']); - $obj->insert(); - } - if (strlen(trim($_POST['other_info'] )) != 0 ) { - $obj->set_type('OTHER'); - $obj->set_value($_POST['other_info']); - $obj->insert(); - } + $obj->save_extra($Ledger->jr_id,$_POST); + echo HtmlInput::button_anchor(_('Nouvelle vente'),$href.'?p_action=ven&sa=n&'.dossier::get()); echo ''; diff --git a/include/ext/dummy/dummy.php b/include/ext/dummy/dummy.php index 3a391931d..dbcc08d0c 100755 --- a/include/ext/dummy/dummy.php +++ b/include/ext/dummy/dummy.php @@ -72,7 +72,7 @@ if ( isset($_POST['start_import'])){ // $array contient toutes les valeurs nécessaires à Fiche::insert, $array=$client->toArray($_POST['fd_id']); - while ( $data=fgetcsv($f)) { + while ( ($data=fgetcsv($f))==true) { // remarque : on a éliminé les traitements d'erreur // On remet tous les attributs (propriétés) à vide diff --git a/include/impress_inc.php b/include/impress_inc.php index c6f7f1d4b..38afe393d 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -257,11 +257,11 @@ echo_debug(__FILE__,__LINE__,"receiving $p_formula"); // then we must modify the cond for the periode $from=str_replace("FROM=","",$afrom[0]); - // Get the periode /*! \note special value for the clause FROM=00.0000 */ if ( $from == '00.0000' ) { + // retrieve the first month of this periode $User=new User($p_cn); $user_periode=$User->get_periode(); @@ -269,8 +269,10 @@ echo_debug(__FILE__,__LINE__,"receiving $p_formula"); $periode=$oPeriode->get_exercice($user_periode); list($first,$last)=$oPeriode->get_limit($periode); $ret=$first->get_date_limit(); + $end_date=$oPeriode->get_date_limit($p_end); if ($ret == null ) throw new Exception ('Pas de limite à cette période',1); - $cond=sql_filter_per($p_cn,$ret['p_start'],$p_end,'date','j_tech_per'); + $cond=sql_filter_per($p_cn,$ret['p_start'],$end_date['p_end'],'date','j_tech_per'); + } else { $oPeriode=new Periode($p_cn); @@ -286,9 +288,9 @@ echo_debug(__FILE__,__LINE__,"receiving $p_formula"); $year=$oPeriode->get_exercice($user_periode); list($first,$last)=$oPeriode->get_limit($year); $ret=$first->get_date_limit(); + $end_date=$oPeriode->get_date_limit($p_end); if ($ret == null ) throw new Exception ('Pas de limite à cette période',1); - $cond=sql_filter_per($p_cn,$ret['p_start'],$p_end,'date','j_tech_per'); - + $cond=sql_filter_per($p_cn,$ret['p_start'],$end_date['p_end'],'date','j_tech_per'); } } } @@ -300,8 +302,6 @@ echo_debug(__FILE__,__LINE__,"receiving $p_formula"); // Get sum of account $P=new Acc_Account_Ledger($p_cn,$e[0]); - echo_debug(__FILE__.":".__LINE__." condition is $cond"); - $detail=$P->get_solde_detail($cond); diff --git a/include/jrn.php b/include/jrn.php index 102847c4f..bdac86a8a 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -185,7 +185,7 @@ function ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1) $r.=""; $r.="Total ".$content['jr_montant']."
"; - if ( $content['jrn_def_type'] == 'VEN' ) { + /* count the number of additionnal info */ $acc_jrn_info=new Acc_Ledger_Info($p_cn); $acc_jrn_info->set_jrn_id($p_jr_id); @@ -203,7 +203,7 @@ function ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1) } } - } + if ( $p_mode==1) { // show all the related operation $rec=new Acc_Reconciliation($p_cn); @@ -567,25 +567,25 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) $_REQUEST['PHPSESSID'], $content['jr_pj_name']).""; $r.=""; - if ( $content['jrn_def_type'] == 'VEN' ) { - /* count the number of additionnal info */ - $acc_jrn_info=new Acc_Ledger_Info($p_cn); - $acc_jrn_info->set_jrn_id($p_jr_id); - - /* if additional info > 0 show them */ - if ( $acc_jrn_info->count() > 0 ) { - $array=$acc_jrn_info->load_all(); - foreach ($array as $row) { - if ( strpos($row->id_type,'BON_COMMANDE') ===0) { - $r.="Num bon de commande : ".$row->ji_value.'
'; - } - if ( strpos($row->id_type,'OTHER') ===0) { - $r.="Autre info : ".$row->ji_value.'
'; - } + /* count the number of additionnal info */ + $acc_jrn_info=new Acc_Ledger_Info($p_cn); + $acc_jrn_info->set_jrn_id($p_jr_id); + + /* if additional info > 0 show them */ + if ( $acc_jrn_info->count() > 0 ) { + $array=$acc_jrn_info->load_all(); + foreach ($array as $row) { + if ( strpos($row->id_type,'BON_COMMANDE') ===0) { + $r.="Num bon de commande : ".$row->ji_value.'
'; } + if ( strpos($row->id_type,'OTHER') ===0) { + $r.="Autre info : ".$row->ji_value.'
'; + } + } } + $r.="
"; if ( $p_mode == 1 ) { $r.= ""; diff --git a/include/template/detail-action.php b/include/template/detail-action.php index e01a310d3..f4dc49b72 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -61,6 +61,8 @@
+ +
@@ -122,7 +124,9 @@
+
+
diff --git a/include/template/form_ledger_detail.php b/include/template/form_ledger_detail.php index bbc4b7e96..10841d5ec 100644 --- a/include/template/form_ledger_detail.php +++ b/include/template/form_ledger_detail.php @@ -58,7 +58,7 @@ echo ''; ?> - +