diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index fcb28f12d..d778550a9 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -3249,7 +3249,16 @@ class Acc_Ledger extends jrn_def_sql return $array; } - function convert_from_follow($p_ag_id) + /** + * @brief convert operations from FOLLOWUP into a SALE , FEENOTE + * or PURCHASE operation into a suitable array + * @param $p_ag_id int PK of ACTION_GESTION + * @param $copy_description int 0 the description of the followup is not copied + * in the note , 1 is copied + * @return array|void|null + * @throws Exception + */ + function convert_from_follow($p_ag_id,$copy_description=0) { global $g_user; if (isNumber($p_ag_id)==0) @@ -3290,6 +3299,13 @@ class Acc_Ledger extends jrn_def_sql $array['e_march'.$i.'_tva_amount']=$a_item[$i]['ad_tva_amount']; $array['e_quant'.$i]=$a_item[$i]['ad_quant']; } + if ( $copy_description == 1) { + $acomment=$this->db->get_array("SELECT agc_id, ag_id, to_char(agc_date,'DD.MM.YYYY HH24:MI') as str_agc_date, agc_comment, agc_comment_raw,tech_user + FROM action_gestion_comment where ag_id=$1 order by agc_id", array($p_ag_id) + ); + if (count ($acomment) > 0) + $array['jrn_note_input']=$acomment[0]['agc_comment']; + } return $array; } diff --git a/include/compta_ach.inc.php b/include/compta_ach.inc.php index b1389ccb8..e09319a97 100644 --- a/include/compta_ach.inc.php +++ b/include/compta_ach.inc.php @@ -252,7 +252,8 @@ try else if (isset($_GET['create_feenote'])) { $action_id=$http->get('ag_id',"number"); - $array=$Ledger->convert_from_follow($action_id); + $cp=$http->get('cp','number',0); + $array=$Ledger->convert_from_follow($action_id,$cp); echo HtmlInput::hidden("ledger_type", "VEN"); echo HtmlInput::hidden("ac",$http->get('ac')); echo HtmlInput::hidden("sa", "p"); diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index c904f2130..b4dc5217c 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -267,7 +267,8 @@ try else if (isset($_GET['create_invoice'])) { $action_id=$http->get('ag_id',"number"); - $array=$Ledger->convert_from_follow($action_id); + $cp=$http->get('cp','number',0); + $array=$Ledger->convert_from_follow($action_id,$cp); echo HtmlInput::hidden("ledger_type", "VEN"); echo HtmlInput::hidden("ac", $http->get('ac')); echo HtmlInput::hidden("sa", "p"); diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index bfdb2b10b..03c4f3aee 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -248,8 +248,8 @@ class HtmlInput /*!\brief create a button with a ref * \param $p_label the text * \param $p_value the location of the window, - * \param $p_name the id of the span - * \param $p_javascript javascript for this button + * \param $p_name the id of the span (button will be "btn".$p_name + * \param $p_javascript javascript for this button, needed to add the event : onclick,... * \return string with htmlcode */ @@ -259,8 +259,8 @@ class HtmlInput $href=""; if ($p_value!="") $href=sprintf(' href ="%s" ', $p_value); - $r=sprintf(' %s', - $p_name, $href, $p_javascript, $p_label); + $r=sprintf(' %s', + $p_name, $p_name,$href, $p_javascript, $p_label); return $r; } /** diff --git a/include/template/follow_up_detail_display.php b/include/template/follow_up_detail_display.php index e68fa8391..25852f565 100644 --- a/include/template/follow_up_detail_display.php +++ b/include/template/follow_up_detail_display.php @@ -200,8 +200,21 @@ $menu=new Default_Menu(); if (Document_Option::is_enable_make_invoice($p_follow_up->dt_id)): ?>
+
Cocher pour copier la description dans la note de la vente
+ Dossier::id(), 'ag_id'=>$p_follow_up->ag_id, 'create_invoice'=>1, 'ac'=>$menu->get('code_invoice'))); + $query=http_build_query(array('gDossier'=>Dossier::id(), 'ag_id'=>$p_follow_up->ag_id, 'create_invoice'=>1,'cp'=>0, 'ac'=>$menu->get('code_invoice'))); echo HtmlInput::button_anchor(_("Transformer en Facture de Vente"), "do.php?".$query, "create_invoice", ' target="_blank" ', "button"); ?> @@ -214,8 +227,21 @@ $menu=new Default_Menu(); if (Document_Option::is_enable_make_feenote($p_follow_up->dt_id)): ?>
+
Cocher pour copier la description dans la note de l'achat ou note de frais
+ Dossier::id(), 'ag_id'=>$p_follow_up->ag_id, 'create_feenote'=>1, 'ac'=>$menu->get('code_feenote'))); + $query=http_build_query(array('cp'=>0,'gDossier'=>Dossier::id(), 'ag_id'=>$p_follow_up->ag_id, 'create_feenote'=>1, 'ac'=>$menu->get('code_feenote'))); echo HtmlInput::button_anchor(_("Transformer en Note de frais ou Facture Achat"), "do.php?".$query, "create_feenote", ' target="_blank" ', "button"); ?> diff --git a/unit-test/include/class/acc_ledgerTest.php b/unit-test/include/class/acc_ledgerTest.php index 73c3dd605..b6c809913 100644 --- a/unit-test/include/class/acc_ledgerTest.php +++ b/unit-test/include/class/acc_ledgerTest.php @@ -1064,4 +1064,44 @@ class Acc_LedgerTest extends TestCase $this->assertEquals($this->object->is_enable(),1); } + + /** + * @testdox convert from FollowUp : Description is asked + * @covers Acc_Ledger::convert_from_follow + * @return void + * @throws Exception + */ + public function testConvert_from_follow_copy1() + { + $action_gestion_id=1; + + $result=$this->object-> convert_from_follow($action_gestion_id,1); + $this->assertTrue($result['jrn_note_input']=='Test',print_r($result,true)); + } + /** + * @testdox convert from FollowUp : Description is not asked + * @covers Acc_Ledger::convert_from_follow + * @return void + * @throws Exception + */ + public function testConvert_from_follow_copy2() + { + $action_gestion_id=1; + + $result=$this->object-> convert_from_follow($action_gestion_id,0); + $this->assertTrue(! isset ($result['jrn_note_input']),print_r($result,true)); + } + /** + * @testdox convert from FollowUp : Description is asked and there is no description available + * @covers Acc_Ledger::convert_from_follow + * @return void + * @throws Exception + */ + public function testConvert_from_follow_copy3() + { + $action_gestion_id=15; + + $result=$this->object-> convert_from_follow($action_gestion_id,1); + $this->assertTrue(! isset ($result['jrn_note_input']),print_r($result,true)); + } }