From b7c10f649c9175edf667894e7536166e9867d417 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 21 Dec 2013 02:23:44 +0000 Subject: [PATCH] task #952 Transforme une action en facture Et correction d'un bug dans la recherche Task #952 - Transform une action en facture --- include/action.common.inc.php | 2 +- include/action.inc.php | 2 +- include/class_acc_ledger.php | 38 ++++++++++++++++++++ include/class_follow_up.php | 46 ++++++++++++------------ include/compta_ven.inc.php | 14 ++++++++ include/template/action_other_action.php | 2 +- include/template/action_search.php | 2 +- include/template/detail-action.php | 19 ++++++++-- 8 files changed, 95 insertions(+), 30 deletions(-) diff --git a/include/action.common.inc.php b/include/action.common.inc.php index c5a7d5e09..0b45a9bfd 100644 --- a/include/action.common.inc.php +++ b/include/action.common.inc.php @@ -227,7 +227,7 @@ if ($sub_action == "list") // Add a button to export to Csv echo '
'; echo HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref", "remind_date","only_internal", "state", "gDossier", "qcode", "start_date", "end_date", "ag_id", "ag_dest_query", - "tdoc", "query","date_start","date_end","hsstate","searchtag")); + "tdoc", "action_query","date_start","date_end","hsstate","searchtag")); echo HtmlInput::hidden("act", "CSV:ActionGestion"); echo HtmlInput::submit("follow_up_csv", "Export CSV",'','smallbutton'); echo "
"; diff --git a/include/action.inc.php b/include/action.inc.php index ab7f68a61..cd5181ed8 100644 --- a/include/action.inc.php +++ b/include/action.inc.php @@ -25,7 +25,7 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); require_once('class_ipopup.php'); global $g_user; $retour=HtmlInput::button_anchor(_('Retour liste'), - HtmlInput::request_to_string(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","ac","gDossier","qcode","ag_dest_query","query","tdoc","date_start","date_end","hsstate","searchtag"))); + HtmlInput::request_to_string(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","ac","gDossier","qcode","ag_dest_query","action_query","tdoc","date_start","date_end","hsstate","searchtag"))); //----------------------------------------------------- // Follow_Up //----------------------------------------------------- diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index db55f8bc5..de352951e 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -3677,6 +3677,44 @@ class Acc_Ledger extends jrn_def_sql $array=$this->get_operation_date(Date('d.m.Y'), 'VEN', '<'); return $array; } + function convert_from_follow($p_ag_id) + { + if (isNumber($p_ag_id)==0) return null; + + $array=array(); + + // retrieve info from action_gestion + $tiers_id=$this->db->get_value('select f_id_dest from action_gestion where ag_id=$1',array($p_ag_id)); + if ( $this->db->size() !=0 ) + $qcode=$this->db->get_value('select j_qcode from vw_poste_qcode where f_id=$1',array($tiers_id)); + else + $qcode=""; + + $comment=$this->db->get_value('select ag_title from action_gestion where ag_id=$1',array($p_ag_id)); + $array['e_client']=$qcode; + $array['e_comm']=$comment; + + // retrieve info from action_detail + $a_item=$this->db->get_array('select f_id,ad_text,ad_pu,ad_quant,ad_tva_id,ad_tva_amount,j_qcode + from + action_detail + left join vw_poste_qcode using(f_id) + where + ag_id=$1',array($p_ag_id)); + $array['nb_item']=$this->db->size(); + for ($i=0;$i<$array['nb_item'];$i++) + { + $array['e_march'.$i]=$a_item[$i]['j_qcode']; + $array['e_march'.$i.'_label']=$a_item[$i]['ad_text']; + $array['e_march'.$i.'_price']=$a_item[$i]['ad_pu']; + $array['e_march'.$i.'_tva_id']=$a_item[$i]['ad_tva_id']; + $array['e_march'.$i.'_tva_amount']=$a_item[$i]['ad_tva_amount']; + $array['e_quant'.$i]=$a_item[$i]['ad_quant']; + + } + return $array; + + } } ?> \ No newline at end of file diff --git a/include/class_follow_up.php b/include/class_follow_up.php index d61bb5465..941acbf31 100644 --- a/include/class_follow_up.php +++ b/include/class_follow_up.php @@ -519,7 +519,7 @@ class Follow_Up /* add the number of item */ $Hid = new IHidden(); $r.=$Hid->input("nb_item", $article_count); - $r.=HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "query", "tdoc", "date_start", "date_end", "hsstate","searchtag")); + $r.=HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate","searchtag")); $a_tag=$this->tag_get(); /* get template */ ob_start(); @@ -693,7 +693,7 @@ class Follow_Up function myList($p_base, $p_filter = "", $p_search = "") { // for the sort - $url = HtmlInput::get_to_string(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "query", "tdoc", "date_start", "date_end", "hsstate","searchtag")) . '&' . $p_base; + $url = HtmlInput::get_to_string(array("closed_action","remind_date_end","remind_date","sag_ref","only_internal","state","qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate","searchtag")) . '&' . $p_base; $table = new Sort_Table(); $table->add('Date Doc.', $url, 'order by ag_timestamp asc', 'order by ag_timestamp desc', 'da', 'dd'); @@ -772,7 +772,7 @@ class Follow_Up //show the sub_action foreach ($a_row as $row) { - $href = ''; + $href = ''; $i++; $tr = ($i % 2 == 0) ? 'even' : 'odd'; if ($row['ag_priority'] < 2) @@ -1140,7 +1140,7 @@ class Follow_Up */ static function display_search($cn, $inner = false) { - $a = (isset($_GET['query'])) ? $_GET['query'] : ""; + $a = (isset($_GET['action_query'])) ? $_GET['action_query'] : ""; $qcode = (isset($_GET['qcode'])) ? $_GET['qcode'] : ""; $supl_hidden = ''; @@ -1286,15 +1286,15 @@ class Follow_Up $p_array = $_GET; extract($p_array); - $query = ""; + $action_query = ""; - if (isset($_REQUEST['query'])) + if (isset($_REQUEST['action_query'])) { // if a query is request build the sql stmt - $query = "and (ag_title ~* '" . sql_string($_REQUEST['query']) . "' " . - "or ag_ref ='" . trim(sql_string($_REQUEST['query'])) . - "' or ag_id in (select ag_id from action_gestion_comment where agc_comment ~* '" . trim(sql_string($_REQUEST['query'])) . "')" . + $action_query = "and (ag_title ~* '" . sql_string($_REQUEST['action_query']) . "' " . + "or ag_ref ='" . trim(sql_string($_REQUEST['action_query'])) . + "' or ag_id in (select ag_id from action_gestion_comment where agc_comment ~* '" . trim(sql_string($_REQUEST['action_query'])) . "')" . ")"; } @@ -1316,15 +1316,15 @@ class Follow_Up } if (isset($tdoc) && $tdoc != -1) { - $query .= ' and dt_id = ' . sql_string($tdoc); + $action_query .= ' and dt_id = ' . sql_string($tdoc); } if (isset($state) && $state!= -1) { - $query .= ' and ag_state= ' . sql_string($state); + $action_query .= ' and ag_state= ' . sql_string($state); } if (isset($hsstate) && $hsstate!= -1) { - $query .= ' and ag_state <> ' . sql_string($hsstate); + $action_query .= ' and ag_state <> ' . sql_string($hsstate); } if (isset($sag_ref) && trim($sag_ref) != "") { @@ -1332,46 +1332,46 @@ class Follow_Up } if (isset($_GET['only_internal'])) - $query .= ' and f_id_dest=0 '; + $action_query .= ' and f_id_dest=0 '; if (isset($date_start) && isDate($date_start) != null) { - $query.=" and ag_timestamp >= to_date('$date_start','DD.MM.YYYY')"; + $action_query.=" and ag_timestamp >= to_date('$date_start','DD.MM.YYYY')"; } if (isset($date_end) && isDate($date_end) != null) { - $query.=" and ag_timestamp <= to_date('$date_end','DD.MM.YYYY')"; + $action_query.=" and ag_timestamp <= to_date('$date_end','DD.MM.YYYY')"; } if (isset($ag_dest_query) && $ag_dest_query != -2 ) { - $query.= " and ((ag_dest = " . sql_string($ag_dest_query)." and ".self::sql_security_filter($cn, "R").") or ". + $action_query.= " and ((ag_dest = " . sql_string($ag_dest_query)." and ".self::sql_security_filter($cn, "R").") or ". " ag_owner='" . $_SESSION['g_user'] . "')"; } else { - $query .=" and (ag_owner='" . $_SESSION['g_user'] . "' or ".self::sql_security_filter($cn, "R")." or ag_dest=-1 )"; + $action_query .=" and (ag_owner='" . $_SESSION['g_user'] . "' or ".self::sql_security_filter($cn, "R")." or ag_dest=-1 )"; } if (isNumber($ag_id) == 1 && $ag_id != 0) { - $query = " and ag_id= " . sql_string($ag_id); + $action_query = " and ag_id= " . sql_string($ag_id); } if ( isset($remind_date) && $remind_date != "" && isDate($remind_date)==$remind_date) { - $query .= " and to_date('".sql_string($remind_date)."','DD.MM.YYYY')<= ag_remind_date"; + $action_query .= " and to_date('".sql_string($remind_date)."','DD.MM.YYYY')<= ag_remind_date"; } if ( isset($remind_date_end) && $remind_date_end != "" && isDate($remind_date_end)==$remind_date_end) { - $query .= " and to_date('".sql_string($remind_date_end)."','DD.MM.YYYY')>= ag_remind_date"; + $action_query .= " and to_date('".sql_string($remind_date_end)."','DD.MM.YYYY')>= ag_remind_date"; } if ( ! isset ($closed_action)) { - $query.=" and s_status is null "; + $action_query.=" and s_status is null "; } if ( isset ($searchtag)) { - $query .= Follow_Up::filter_by_tag($cn,$p_array); + $action_query .= Follow_Up::filter_by_tag($cn,$p_array); } - return $query . $str; + return $action_query . $str; } /** diff --git a/include/compta_ven.inc.php b/include/compta_ven.inc.php index e09273968..8f1e034fd 100644 --- a/include/compta_ven.inc.php +++ b/include/compta_ven.inc.php @@ -207,6 +207,20 @@ echo '
'; echo 'compute_all_ledger();'; echo ''; } + else if ( isset ($_GET['create_invoice'])) + { + $array=$Ledger->convert_from_follow($_GET ['ag_id']); + echo HtmlInput::hidden("ledger_type","VEN"); + echo HtmlInput::hidden("ac",$_REQUEST['ac']); + echo HtmlInput::hidden("sa","p"); + echo $Ledger->input($array); + echo '
'; + echo $Ledger->input_paid(); + echo '
'; + echo ''; + } else { echo HtmlInput::hidden("ledger_type","VEN"); diff --git a/include/template/action_other_action.php b/include/template/action_other_action.php index 7941042ee..386a084d8 100644 --- a/include/template/action_other_action.php +++ b/include/template/action_other_action.php @@ -8,7 +8,7 @@ * Hidden values for a previous search */ echo HtmlInput::request_to_hidden(array("closed_action","remind_date_end","remind_date","sag_ref", "remind_date","only_internal", "state", "gDossier", "qcode", "start_date", "end_date", "ag_id", "ag_dest_query", - "tdoc", "query","date_start","date_end","hsstate","searchtag")); + "tdoc", "action_query","date_start","date_end","hsstate","searchtag")); ?> -
+ - - +
+ + +
+
+ag_id != 0 && ! $readonly) : ?> +
+

+ Dossier::id(),'ag_id'=>$this->ag_id,'create_invoice'=>1,'ac'=>'VEN')); + echo HtmlInput::button_anchor("Transformer en facture","do.php?".$query,"create_invoice", "","button"); + ?> +

+
+