From 47cb4285d9eef2791e0ebb0c2d492dc35616a16a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Fri, 2 Oct 2020 18:23:37 +0200 Subject: [PATCH] Fix: predefined operation with overflow for details Follow Up : operation detail moved from Follow_up to Follow_Up_Detail Add Option for Follow Up Add option for contact in follow up rename cfgcat to cfgaction rewriting of cfgcatdoc --- html/ajax_misc.php | 58 +----- html/js/scripts.js | 28 ++- include/cat_document.inc.php | 90 --------- include/cfg_action.inc.php | 44 ++++ .../action_document_type_mtable.class.php | 190 +++++++++++++++++ include/class/document_option.class.php | 88 ++++++++ include/class/document_type.class.php | 42 +--- include/class/follow_up.class.php | 111 +--------- include/class/follow_up_detail.class.php | 5 + .../class/operation_predef_mtable.class.php | 2 +- include/class/pre_op_advanced.class.php | 5 +- .../database/contact_option_ref_sql.class.php | 66 ++++++ include/lib/manage_table_sql.class.php | 13 +- include/template/detail-action.php | 151 ++++---------- include/template/document_mod_change.php | 87 -------- include/template/follow_up_detail_display.php | 191 ++++++++++++++++++ include/template/predf_ledger_detail.php | 2 +- sql/upgrade.sql | 91 +++++++++ 18 files changed, 771 insertions(+), 493 deletions(-) delete mode 100644 include/cat_document.inc.php create mode 100644 include/cfg_action.inc.php create mode 100644 include/class/action_document_type_mtable.class.php create mode 100644 include/class/document_option.class.php create mode 100644 include/database/contact_option_ref_sql.class.php delete mode 100644 include/template/document_mod_change.php create mode 100644 include/template/follow_up_detail_display.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 2e2e258f3..3ac6686d7 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -257,7 +257,11 @@ $path = array( // payment_method "payment_method"=>"ajax_payment_method", // update list of predefined operation if ledger changes - "up_predef"=>"ajax_update_predef" + "up_predef"=>"ajax_update_predef", + // cfgaction type of document + "cfgaction"=>'ajax_cfgaction', + // list options for multiple contact + "contact_option_list"=>'ajax_contact_option_list' ) ; if (array_key_exists($op, $path)) { @@ -388,58 +392,8 @@ EOF; EOF; break; - /* rem a cat of document */ - case 'rem_cat_doc': - require_once NOALYSS_INCLUDE.'/class/document_type.class.php'; - // if user can not return error message - $message=""; - if ($g_user->check_action(PARCATDOC) == 0) - { - $html = "nok"; - $message=_('Action non autorisée'); - header('Content-type: text/xml; charset=UTF-8'); - echo << - -$html -$message - -EOF; - return; - } - // remove the cat if no action - $count_md = $cn->get_value('select count(*) from document_modele where md_type=$1', array($dt_id)); - $count_a = $cn->get_value('select count(*) from action_gestion where ag_type=$1', array($dt_id)); + - if ($count_md != 0 || $count_a != 0) - { - $message=_('Des actions dépendent de cette catégorie'); - $html = "nok"; - header('Content-type: text/xml; charset=UTF-8'); - echo << - -$html -$message - -EOF; - exit; - } - $cn->exec_sql('delete from document_type where dt_id=$1', array($dt_id)); - $html = $dt_id; - header('Content-type: text/xml; charset=UTF-8'); - echo << - -$html -$message - -EOF; - return; - break; - case 'mod_cat_doc': - require_once NOALYSS_TEMPLATE.'/document_mod_change.php'; - break; case 'dsp_tva': $cn = Dossier::connect(); // Filter the VAT diff --git a/html/js/scripts.js b/html/js/scripts.js index 3bd5e758e..f5907020f 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -26,7 +26,25 @@ var ask_reload = 0; var tag_choose = ''; var aDraggableElement = new Array(); - +/** + * return undefined if nothing is found , otherwise return the DOM elemnt + * @param {type} p_name_dom + * @param {type} name_child + * @returns {undefined} + */ +function in_child(p_element,name_child) { + var element=p_element + if ( typeof p_element !== "object" ) { + element=document.getElementById(p_element); + + } + if ( ! element ) return undefined; + for ( var e=0; e < element.childElementCount;e++) { + if ( element.childNodes[e].id == name_child) { + return element.childNodes[e]; + } + } +} /** * callback function when we just need to update a hidden div with an info * message @@ -2115,7 +2133,13 @@ function view_action(ag_id, dossier, modify) }); $(id).innerHTML = code_html; if (ctl_txt == 'ok') { - compute_all_ledger(); + // compute detail + var detail=in_child(id,"follow_up_detail"); + if (detail) { + compute_all_ledger(); + } + + } code_html.evalScripts(); } catch (e) { diff --git a/include/cat_document.inc.php b/include/cat_document.inc.php deleted file mode 100644 index fe3a7b31c..000000000 --- a/include/cat_document.inc.php +++ /dev/null @@ -1,90 +0,0 @@ -post('cat'); - $prefix=$http->post('prefix'); - $catDoc->insert($cat, $prefix); - } - catch (Exception $exc) - { - echo $exc->getMessage(); - error_log($exc->getTraceAsString()); - } -} -if (isset($_POST['save'])) -{ - try - { - $dt_id=$http->post("dt_id", "number"); - $name= - $prefix= - $catDoc=new Document_Type($cn, $dt_id); - $catDoc->get(); - $catDoc->dt_value=trim($http->post("dt_name"));; - $catDoc->dt_prefix=trim($http->post("dt_prefix")); - if ($catDoc->dt_value=="") - { - alert(_("Le nom ne peut pas être vide")); - } - else - { - $catDoc->update(); - } - if ($_POST['seq']!=0&&isNumber($_POST['seq'])==1) - { - $catDoc->set_number($_POST['seq']); - } - } - catch (Exception $exc) - { - alert ($exc->getMessage()); - error_log($exc->getTraceAsString()); - } -} -$aList=Document_Type::get_list($cn); -$addCat=new IText('cat'); -$addPrefix=new IText('prefix'); -$str_addCat=$addCat->input(); -$str_addPrefix=$addPrefix->input(); -$str_submit=HtmlInput::submit('add', _('Ajout')); -echo '
'; -require_once NOALYSS_TEMPLATE.'/list_category_document.php'; - -echo '
'; -?> diff --git a/include/cfg_action.inc.php b/include/cfg_action.inc.php new file mode 100644 index 000000000..77a29baef --- /dev/null +++ b/include/cfg_action.inc.php @@ -0,0 +1,44 @@ +'; +$doc_type=new Document_type_SQL($cn); +$action_document_type=new Action_Document_Type_MTable($doc_type); + +$action_document_type->set_callback("ajax_misc.php"); +$action_document_type->add_json_param("op", "cfgaction"); + +$action_document_type->create_js_script(); +$action_document_type->display_table("order by dt_value"); +?> + + + + \ No newline at end of file diff --git a/include/class/action_document_type_mtable.class.php b/include/class/action_document_type_mtable.class.php new file mode 100644 index 000000000..b6fb26376 --- /dev/null +++ b/include/class/action_document_type_mtable.class.php @@ -0,0 +1,190 @@ + + +/* @file + * @brief display and allow to update , add , delete document_type for the follow up + * + */ +require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php"; +require_once NOALYSS_INCLUDE."/database/document_type_sql.class.php"; + +/** + * @class + * @brief display , modify and add document_type for follow up + * @see include/ajax/ajax_cfgaction.php + * @see include/cfg_action.inc.php + */ +class Action_Document_Type_MTable extends Manage_Table_SQL +{ + + private $other; //!< Other value + + public function __construct(Document_type_SQL $doc_type) + { + parent::__construct($doc_type); + $this->set_order(["dt_id", "dt_prefix", "dt_value",]); + $this->set_property_updatable("dt_id", false); + $this->set_property_visible("dt_id", false); + $this->set_property_updatable("dt_value", true); + $this->set_property_updatable("dt_prefix", true); + $this->set_col_label("dt_value", _("Nom")); + $this->set_col_label("dt_prefix", _("Préfixe document")); + $this->other=array(); + } + + /** + * + @code + table "public.document_type" + ctl_id "dtr" + gDossier "74" + op "cfgaction" + p_id "28" + action "save" + ctl "tbl5f785d403b123" + dt_prefix "ABO.HEB" + dt_value "Abonnements+PhpCompta" + seq "0" + det_op "1" + det_contact_mul "1" + update "OK" + @endcode + * + * + * + */ + public function from_request() + { + $http=new HttpInput(); + $this->table->dt_value=$http->request('dt_value'); + $this->table->dt_prefix=$http->request('dt_prefix'); + $this->other['detail_operation']=$http->request("detail_operation", "string", 0); + $this->other['contact_multiple']=$http->request("det_contact_mul", "string", 0); + $this->other['make_invoice']=$http->request("make_invoice", "string", 0); + $this->other['seq']=$http->request("seq", "string", 0); + } + + /** + * + */ + public function check() + { + $table=$this->get_table(); + $error=0; + if (empty(trim($table->dt_value))) + { + $this->set_error("dt_value", _("Nom ne peut être vide")); + $error++; + } + if (empty(trim($table->dt_prefix))) + { + $this->set_error("dt_prefix", _("Préfixe ne peut être vide")); + $error++; + } + // Check doublon + if ($table->cn->get_value('select count(*) from document_type where upper(dt_value)=upper($1) and dt_id <> $2', + [$table->dt_value, $table->dt_id])>0) + { + $this->set_error("dt_value", _("Doublon, ce nom existe déjà ")); + $error++; + } + // Check doublon + if ($table->cn->get_value('select count(*) from document_type where upper(dt_prefix)=upper($1) and dt_id <> $2', + [$table->dt_prefix, $table->dt_id])>0) + { + $this->set_error("dt_value", _("Doublon, ce préfixe existe déjà ")); + $error++; + } + if ($error>0) + return false; + return true; + } + + /** + * + * @throws Exception + */ + function delete() + { + $table=$this->get_table(); + try + { + // remove the cat if no action + $count_md=$table->cn->get_value('select count(*) from document_modele where md_type=$1', + array($table->dt_id)); + $count_a=$table->cn->get_value('select count(*) from action_gestion where ag_type=$1', array($table->dt_id)); + + if ($count_md!=0||$count_a!=0) + { + throw new Exception(_('Des actions dépendent de cette catégorie'), 1300); + } + $table->delete(); + } + catch (Exception $exc) + { + if ($exc->getCode()!=1300) + { + record_log("ADTM01".$exc->getTrace()); + } + throw new Exception($exc->getMessage()); + } + } + + /** + * @brief display the box for adding, the name for p_id , are in the form + */ + function input() + { + parent::input(); + require NOALYSS_TEMPLATE."/action_document_type_mtable_input.php"; + } + + /** + * save + */ + function save() + { + parent::save(); + $cn=Dossier::connect(); + $object_sql=$this->get_table(); + // restart sequence + if ($this->other['seq']!=0) + { + $doc_type=new Document_type($cn, $object_sql->dt_id); + $doc_type->set_number($this->other['seq']); + } + // Save detail operation + $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) + on conflict on constraint document_option_un + do update set do_enable=$3", ["detail_operation", $object_sql->dt_id, $this->other['detail_operation']]); + + // Save contact_multiple + $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) + on conflict on constraint document_option_un + do update set do_enable=$3 ", ["contact_multiple", $object_sql->dt_id, $this->other['contact_multiple']]); + + // Save make invoice + $cn->exec_sql("insert into document_option (do_code,document_type_id,do_enable) values ($1,$2,$3) + on conflict on constraint document_option_un + do update set do_enable=$3 ", ["make_invoice", $object_sql->dt_id, $this->other['make_invoice']]); + } + +} diff --git a/include/class/document_option.class.php b/include/class/document_option.class.php new file mode 100644 index 000000000..5d68874bd --- /dev/null +++ b/include/class/document_option.class.php @@ -0,0 +1,88 @@ + + +/** + * @file + * @brief + */ + +/** + * @class + * @brief + */ +class Document_Option +{ + + /** + * returns true if the operation_detail is enable, otherwise false + * + * @param int $p_document_type Document_Type.dt_id + * @return boolean + */ + static function is_enable_operation_detail($p_document_type) + { + $display_operation=false; + $cn=Dossier::connect(); + if ($cn->get_value("select do_enable from document_option where document_type_id=$1 and do_code = $2", + [$p_document_type, 'detail_operation'])=='1') + { + $display_operation=true; + } + return $display_operation; + } + + /** + * returns true if the operation_detail is enable, otherwise false + * + * @param int $p_document_type Document_Type.dt_id + * @return boolean + */ + static function is_enable_contact_multiple($p_document_type) + { + $return=false; + $cn=Dossier::connect(); + if ($cn->get_value("select do_enable from document_option where document_type_id=$1 and do_code = $2", + [$p_document_type, 'contact_multiple'])=='1') + { + $return=true; + } + return $return; + } + + /** + * returns true if the operation_detail is enable, otherwise false + * + * @param int $p_document_type Document_Type.dt_id + * @return boolean + */ + static function is_enable_make_invoice($p_document_type) + { + $return=false; + $cn=Dossier::connect(); + if ($cn->get_value("select do_enable from document_option where document_type_id=$1 and do_code = $2", + [$p_document_type, 'make_invoice'])=='1') + { + $return=true; + } + return $return; + } + +} diff --git a/include/class/document_type.class.php b/include/class/document_type.class.php index 8f0d2fbf1..946202604 100644 --- a/include/class/document_type.class.php +++ b/include/class/document_type.class.php @@ -23,7 +23,9 @@ * \brief class for the table document_type */ -/** \brief class for the table document_type +/** \ + *@brief class for the table document_type , a document_type is a kind of action in the follow up + * * < dt_id pk document_type * < dt_value value */ @@ -91,40 +93,10 @@ class Document_type return $array; } - function insert($p_value, $p_prefix) - { - $sql = "insert into document_type(dt_value,dt_prefix) values ($1,$2)"; - try - { - if ($this->db->count_sql('select * from document_type where upper(dt_value)=upper(trim($1))', array($p_value)) > 0) - throw new Exception('Nom en double'); - if (strlen(trim($p_value)) > 0) - $this->db->exec_sql($sql, array($p_value, $p_prefix)); - } - catch (Exception $e) - { - record_log($e); - alert(j(_("Impossible d'ajouter [$p_value] ") . $e->getMessage())); - } - } - - /** - * Update - */ - function update() - { - try - { - $this->db->exec_sql("update document_type set dt_value=$1,dt_prefix=$2 where dt_id=$3", array($this->dt_value, - $this->dt_prefix, $this->dt_id)); - } - catch (Exception $e) - { - record_log($e); - alert(" Erreur " . $e->getMessage()); - } - } - + /** + * Restart the increment of the document + * @param type $p_int + */ function set_number($p_int) { try diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 48ad1e2ea..3aa0b6dde 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -31,6 +31,7 @@ require_once NOALYSS_INCLUDE.'/class/fiche.class.php'; require_once NOALYSS_INCLUDE.'/class/document.class.php'; require_once NOALYSS_INCLUDE.'/class/document_type.class.php'; require_once NOALYSS_INCLUDE.'/class/document_modele.class.php'; +require_once NOALYSS_INCLUDE.'/class/document_option.class.php'; require_once NOALYSS_INCLUDE.'/lib/user_common.php'; require_once NOALYSS_INCLUDE.'/class/follow_up_detail.class.php'; require_once NOALYSS_INCLUDE.'/lib/inum.class.php'; @@ -152,7 +153,7 @@ class Follow_Up * * \return string containing the html code */ - function Display($p_view, $p_gen, $p_base, $retour="") + function display($p_view, $p_gen, $p_base, $retour="") { global $g_user; if ($p_view=='UPD') @@ -175,6 +176,8 @@ class Follow_Up { throw new Exception('class_action'.__LINE__.'Follow_Up::Display error unknown parameter'.$p_view); } + + // Compute the widget // Date $date=new IDate(); @@ -428,108 +431,9 @@ class Follow_Up $text=new IText(); $num=new INum(); - /* TVA */ - $itva=new ITva_Popup($this->db); - $itva->in_table=true; - $aCard=array(); - /* create aArticle for the detail section */ - $article_count=(count($this->aAction_detail)==0)?MAX_ARTICLE:count($this->aAction_detail); - /* Compute total */ - $tot_item=0; - $tot_vat=0; - for ($i=0; $i<$article_count; $i++) - { - /* fid = Icard */ - $icard=new ICard(); - $icard->jrn=0; - $icard->table=0; - $icard->noadd="no"; - $icard->extra='all'; - $icard->name="e_march".$i; - $tmp_ad=(isset($this->aAction_detail[$i]))?$this->aAction_detail[$i]:false; - $icard->readOnly=$readonly; - $icard->value=''; - $aCard[$i]=0; - if ($tmp_ad) - { - $march=new Fiche($this->db); - $f=$tmp_ad->get_parameter('qcode'); - if ($f!=0) - { - $march->id=$f; - $icard->value=$march->get_quick_code(); - $aCard[$i]=$f; - } - } - $icard->set_dblclick("fill_ipopcard(this);"); - // name of the field to update with the name of the card - $icard->set_attribute('label', "e_march".$i."_label"); - // name of the field to update with the name of the card - $icard->set_attribute('typecard', $icard->extra); - $icard->set_attribute('ipopup', 'ipopcard'); - $icard->set_function('fill_data'); - $icard->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ', $icard->name); - - $aArticle[$i]['fid']=$icard->search().$icard->input(); - - $text->javascript=' onchange="clean_tva('.$i.');compute_ledger('.$i.')"'; - $text->css_size="100%"; - $text->name="e_march".$i."_label"; - $text->id="e_march".$i."_label"; - $text->size=40; - $text->value=($tmp_ad)?$tmp_ad->get_parameter('text'):""; - $text->readOnly=$readonly; - $aArticle[$i]['desc']=$text->input(); - - $num->javascript=' onchange="format_number(this,4);clean_tva('.$i.');compute_ledger('.$i.')"'; - $num->name="e_march".$i."_price"; - $num->id="e_march".$i."_price"; - $num->size=8; - $num->readOnly=$readonly; - $num->value=($tmp_ad)?$tmp_ad->get_parameter('price_unit'):0; - $aArticle[$i]['pu']=$num->input(); - - $num->name="e_quant".$i; - $num->id="e_quant".$i; - $num->size=8; - $num->value=($tmp_ad)?$tmp_ad->get_parameter('quantity'):0; - $aArticle[$i]['quant']=$num->input(); - - $itva->name='e_march'.$i.'_tva_id'; - $itva->id='e_march'.$i.'_tva_id'; - $itva->value=($tmp_ad)?$tmp_ad->get_parameter('tva_id'):0; - $itva->readOnly=$readonly; - $itva->js=' onchange="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"'; - $itva->set_attribute('compute', $i); - - $aArticle[$i]['tvaid']=$itva->input(); - - $num->name="e_march".$i."_tva_amount"; - $num->id="e_march".$i."_tva_amount"; - $num->value=($tmp_ad)?$tmp_ad->get_parameter('tva_amount'):0; - $num->javascript=" onchange=\"compute_ledger('".$i." ')\""; - $num->size=8; - $aArticle[$i]['tva']=$num->input(); - $tot_vat=bcadd($tot_vat,$num->value); - - $num->name="tvac_march".$i; - $num->id="tvac_march".$i; - $num->value=($tmp_ad)?$tmp_ad->get_parameter('total'):0; - $num->size=8; - $aArticle[$i]['tvac']=$num->input(); - $tot_item=bcadd($tot_item,$num->value); - - $aArticle[$i]['hidden_htva']=HtmlInput::hidden('htva_march'.$i, 0); - $aArticle[$i]['hidden_tva']=HtmlInput::hidden('tva_march'.$i, 0); - $aArticle[$i]['ad_id']=($tmp_ad)?HtmlInput::hidden('ad_id'.$i, $tmp_ad->get_parameter('id')):HtmlInput::hidden('ad_id'.$i, 0); - } - /* Add the needed hidden values */ $r.=dossier::hidden(); - /* 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", "action_query", "tdoc", "date_start", "date_end", "hsstate", "searchtag")); $a_tag=$this->tag_get(); $menu=new Default_Menu(); @@ -671,9 +575,10 @@ class Follow_Up $this->ag_remind_date /* 13 */ ) ); - + $http=new HttpInput(); + $nb_item=$http->post("nb_item","number",0); /* insert also the details */ - for ($i=0; $i<$_POST['nb_item']; $i++) + for ($i=0; $i<$nb_item; $i++) { $act=new Follow_Up_Detail($this->db); $act->from_array($_POST, $i); @@ -861,7 +766,7 @@ class Follow_Up * * \return true on success otherwise false */ - function Update() + function update() { // if ag_id == 0 nothing to do diff --git a/include/class/follow_up_detail.class.php b/include/class/follow_up_detail.class.php index fdb39abfd..0967d99ea 100644 --- a/include/class/follow_up_detail.class.php +++ b/include/class/follow_up_detail.class.php @@ -233,6 +233,11 @@ class Follow_Up_Detail if (trim($this->ad_total_amount)==""||isNumber($this->ad_total_amount)==0) $this->ad_total_amount=0; if (trim($this->ad_tva_id)=="" || isNumber($this->ad_tva_id)==0) $this->ad_tva_id=0; } + + public static function display(Follow_Up $p_follow_up,$p_view) + { + require NOALYSS_TEMPLATE."/follow_up_detail_display.php"; + } /*!\brief *\param *\return diff --git a/include/class/operation_predef_mtable.class.php b/include/class/operation_predef_mtable.class.php index ceae85b6b..a425c3e46 100644 --- a/include/class/operation_predef_mtable.class.php +++ b/include/class/operation_predef_mtable.class.php @@ -67,7 +67,7 @@ class Operation_Predef_MTable extends Manage_Table_SQL // create our own "Append button" $this->set_append_row(false); $this->set_dialog_box("prdfop"); - $this->set_dialogbox_style(["position"=>"absolute","top"=>"5%","width:auto","min-width"=>"80%"]); + $this->set_dialogbox_style(["position"=>"fixed","top"=>"5%","width:auto","min-width"=>"80%"]); } /** diff --git a/include/class/pre_op_advanced.class.php b/include/class/pre_op_advanced.class.php index b870ef17a..e1e45ec14 100644 --- a/include/class/pre_op_advanced.class.php +++ b/include/class/pre_op_advanced.class.php @@ -191,8 +191,8 @@ class Pre_Op_Advanced extends Pre_operation_detail $ret.=HtmlInput::hidden('jrn_type', "ODS"); $info = Icon_Action::infobulle(0); $info_poste = Icon_Action::infobulle(9); - if ($g_user->check_action(FICADD) == 1) - $ret.=$f_add_button->input(); + if ($g_user->check_action(FICADD) == 1) $ret.=$f_add_button->input(); + $ret.='
'; $ret.=''; $ret.='' . '' . @@ -287,6 +287,7 @@ class Pre_Op_Advanced extends Pre_operation_detail // If readonly == 1 then show CA } $ret.='
Quickcode' . $info . '
'; + $ret.="
"; $ret.=Html_Input_Noalyss::ledger_add_item("M"); return $ret; } diff --git a/include/database/contact_option_ref_sql.class.php b/include/database/contact_option_ref_sql.class.php new file mode 100644 index 000000000..5e3906094 --- /dev/null +++ b/include/database/contact_option_ref_sql.class.php @@ -0,0 +1,66 @@ + + +require_once NOALYSS_INCLUDE.'/lib/noalyss_sql.class.php'; +require_once NOALYSS_INCLUDE.'/class/database.class.php'; + +/** + * class_contact_option_ref_sql.php + * + * @file + * @brief abstract of the table public.contact_option_ref */ +class Contact_option_ref_SQL extends Noalyss_SQL +{ + + function __construct(Database $p_cn, $p_id=-1) + { + $this->table="public.contact_option_ref"; + $this->primary_key="cor_id"; + /* + * List of columns + */ + $this->name=array( + "cor_id"=>"cor_id" + , "cor_label"=>"cor_label" + , "cor_type"=>"cor_type" + , "cor_value_select"=>"cor_value_select" + ); + /* + * Type of columns + */ + $this->type=array( + "cor_id"=>"numeric" + , "cor_label"=>"text" + , "cor_type"=>"numeric" + , "cor_value_select"=>"text" + ); + + + $this->default=array( + "cor_id"=>"auto" + ); + + $this->date_format="DD.MM.YYYY"; + parent::__construct($p_cn, $p_id); + } + +} diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index 20784304a..0c7d3e636 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -61,6 +61,7 @@ * @see sorttable.js * */ +require_once NOALYSS_INCLUDE."/lib/http_input.class.php"; class Manage_Table_SQL { @@ -258,7 +259,7 @@ class Manage_Table_SQL } /** - * This function can be overrided to check the data before + * @brief This function can be overrided to check the data before * inserting , updating or removing, above an example of an overidden check. * * Usually , you get the row of the table (get_table) , you check the conditions @@ -268,7 +269,8 @@ class Manage_Table_SQL * * @see set_error get_error count_error * @return boolean - * @code + * +@code function check() { global $cn; @@ -292,7 +294,7 @@ function check() if ( $is_error > 0 ) return false; return true; } - * @endcode +@endcode */ function check() { @@ -776,6 +778,7 @@ function check() function from_request() { $nb=count($this->a_order); + $http=new HttpInput(); for ($i=0; $i<$nb; $i++) { @@ -783,7 +786,7 @@ function check() if ($this->get_property_visible($key)==TRUE&&$this->get_property_updatable($key) ==TRUE) { - $v=HtmlInput::default_value_request($this->a_order[$i], ""); + $v=$http->request($this->a_order[$i],"string",""); $this->table->$key=strip_tags($v); } } @@ -1094,7 +1097,7 @@ function check() ob_start(); - echo HtmlInput::title_box("Donnée", $this->dialog_box,"close","","y"); + echo HtmlInput::title_box(_("Donnée"), $this->dialog_box,"close","","y"); printf('
', $this->object_name, $this->table->get_pk_value(), $this->object_name, $this->object_name, diff --git a/include/template/detail-action.php b/include/template/detail-action.php index 0ecc3bd3f..515559014 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -7,7 +7,7 @@ $uniq=uniqid("tab",TRUE); - + @@ -57,6 +57,7 @@ $uniq=uniqid("tab",TRUE); echo _('Pas de catégorie de contact'); endif; endif; + ?> @@ -65,7 +66,7 @@ $uniq=uniqid("tab",TRUE); input(); ?> - ag_id > 0 ): ?> + ag_id > 0 && Document_Option::is_enable_contact_multiple($this->dt_id)): ?>
@@ -280,132 +281,52 @@ echo ''; - - - - ag_id > 0 && Document_Option::is_enable_operation_detail($this->dt_id)) Follow_Up_Detail::display($this,$p_view); - ?> -
- - - -
- - - - - - - - - + + +
- - - - - - - - - - - - - - -
-
- - - - -
-
-
-
-
-
-
-
Total HTVA -
Total TVA -
Total TVAC -
+
+ + + +
+ - -
- - "> -
- - - + - -
-ag_id != 0 && ! $readonly) : ?> -
-

- Dossier::id(),'ag_id'=>$this->ag_id,'create_invoice'=>1,'ac'=>$menu->get('code_invoice'))); - echo HtmlInput::button_anchor(_("Transformer en facture"),"do.php?".$query,"create_invoice", ' target="_blank" ',"button"); - ?> -

-
- - -
- - -
- - - -
- - - + + +
ag_timestamp ?> par ag_ow - + + dt_id)): + ?> +

+ Dossier::id(), 'ag_id'=>$p_follow_up->ag_id, 'create_invoice'=>1, 'ac'=>$menu->get('code_invoice'))); + echo HtmlInput::button_anchor(_("Transformer en facture"), "do.php?".$query, "create_invoice", + ' target="_blank" ', "button"); + ?> +

+ \ No newline at end of file diff --git a/include/template/predf_ledger_detail.php b/include/template/predf_ledger_detail.php index d46eff899..2174ea1d1 100644 --- a/include/template/predf_ledger_detail.php +++ b/include/template/predf_ledger_detail.php @@ -8,7 +8,7 @@ -
+

diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 8dac2066e..1dae36d28 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -49,3 +49,94 @@ LANGUAGE plpgsql; ALTER TABLE public.user_sec_action_profile drop CONSTRAINT user_sec_action_profile_ua_right_check; ALTER TABLE public.user_sec_action_profile ADD CONSTRAINT user_sec_action_profile_ua_right_check check (ua_right in ('R','W','X','O')); +-- extension CRM : definition des options qu'on peut ajouter +-- public.document_option_ref definition + +-- Drop table + +-- DROP TABLE public.document_option_ref; + +CREATE TABLE public.document_option_ref ( + do_id bigserial NOT NULL, + do_code varchar(20) NOT NULL, -- Code of the option to add + document_type_id int8 NULL, -- FK to document_type + CONSTRAINT document_option_ref_pk PRIMARY KEY (do_id) +); +COMMENT ON TABLE public.document_option_ref IS 'Reference of option of document_type'; + +-- Column comments + +COMMENT ON COLUMN public.document_option_ref.do_code IS 'Code of the option to add'; +COMMENT ON COLUMN public.document_option_ref.document_type_id IS 'FK to document_type'; + + +-- public.document_option_ref foreign keys + +ALTER TABLE public.document_option_ref ADD CONSTRAINT document_option_ref_fk FOREIGN KEY (document_type_id) REFERENCES document_type(dt_id) ON UPDATE CASCADE ON DELETE CASCADE; + + +-- Drop table + +CREATE TABLE public.contact_option_ref ( + cor_id bigserial NOT NULL, + cor_label varchar NOT NULL, -- Label de l'option + cor_type int4 NOT NULL DEFAULT 0, -- 0 text , 1 select ,2 nombre , 3 date + cor_value_json json NULL, -- json object if cor_type is a select + document_option_id int8 NOT NULL, -- FK to document_option + CONSTRAINT contact_option_ref_pk PRIMARY KEY (cor_id), + CONSTRAINT contact_option_ref_fk FOREIGN KEY (document_option_id) REFERENCES document_option(do_id) ON UPDATE CASCADE ON DELETE CASCADE +); +COMMENT ON TABLE public.contact_option_ref IS 'Option for the contact'; + +-- Column comments + +COMMENT ON COLUMN public.contact_option_ref.cor_label IS 'Label de l''option'; +COMMENT ON COLUMN public.contact_option_ref.cor_type IS '0 text , 1 select ,2 nombre , 3 date'; +COMMENT ON COLUMN public.contact_option_ref.cor_value_json IS 'json object if cor_type is a select'; +COMMENT ON COLUMN public.contact_option_ref.document_option_id IS 'FK to document_option'; + + +CREATE TABLE public.action_person_option ( + ap_id bigserial NOT NULL, + ap_value varchar NULL, -- Value of the option + contact_option_ref_id int8 NOT NULL, + action_person_id int8 NOT NULL, + CONSTRAINT action_person_option_pk PRIMARY KEY (ap_id), + CONSTRAINT action_person_option_fk FOREIGN KEY (action_person_id) REFERENCES action_person(ap_id) ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT contact_option_ref_fk FOREIGN KEY (contact_option_ref_id) REFERENCES contact_option_ref(cor_id) ON UPDATE CASCADE ON DELETE CASCADE +); +COMMENT ON TABLE public.action_person_option IS 'option for each contact'; + +-- Column comments + +COMMENT ON COLUMN public.action_person_option.ap_value IS 'Value of the option'; + +-- renomme le menu +update menu_ref set me_description = 'Configuration des documents dans le suivi' ,me_file='cfg_action.inc.php' , +me_description_etendue ='Vous permet d''ajouter de nouveaux type de documents pour le suivi (bordereau de livraison, devis..)',me_code='CFGACTION', +me_menu='Document Suivi' +where me_code='CFGCATDOC'; + + +ALTER TABLE public.document_option ADD do_activate int NOT NULL DEFAULT 1; +COMMENT ON COLUMN public.document_option.do_activate IS '1 the option is activated, 0 is inativated'; + +ALTER TABLE public.document_option ADD CONSTRAINT document_option_un UNIQUE (do_code,document_type_id); +ALTER TABLE public.document_option RENAME COLUMN do_activate TO do_enable; + +-- ajoute un menu pour les options de contacts +INSERT INTO public.menu_ref (me_code,me_menu,me_file,me_url,me_description,me_parameter,me_javascript,me_type,me_description_etendue) VALUES +('CFGCONTACT','Contact','contact_option_ref.inc.php',NULL,'Configure les options pours les contacts multiples',NULL,NULL,'ME',NULL) +; + +INSERT INTO public.profile_menu (me_code,me_code_dep,p_id,p_order,p_type_display,pm_default,pm_id_dep) VALUES +('CFGCONTACT','DIVPARM',1,85,'E',0,56) +; + +-- contact option globale pour toutes les actions +ALTER TABLE public.contact_option_ref DROP COLUMN document_option_id; + +-- on utilise un varchar pour stocker les possibilités +ALTER TABLE public.contact_option_ref DROP COLUMN cor_value_json; +ALTER TABLE public.contact_option_ref ADD cor_value_select varchar NULL; +COMMENT ON COLUMN public.contact_option_ref.cor_value_select IS 'Select values'; \ No newline at end of file