diff --git a/html/ajax_card.php b/html/ajax_card.php index 3906c6e9c..aabc26745 100644 --- a/html/ajax_card.php +++ b/html/ajax_card.php @@ -431,6 +431,16 @@ case 'fs': $ctl=$ctl.'_content'; $html=$r; break; + case 'action_add_concerned_card': + require_once 'ajax_add_concerned_card.php'; + return; + break; + case 'action_save_concerned': + require 'ajax_action_save_concerned.php'; + return; + case 'action_remove_concerned': + require 'ajax_action_remove_concerned.php'; + return; case 'ac': if ( $g_user->check_action(FICCAT)==1 ) { diff --git a/html/js/card.js b/html/js/card.js index 166dabd4c..10eb78d04 100644 --- a/html/js/card.js +++ b/html/js/card.js @@ -113,6 +113,115 @@ function search_card(obj) alert('search_card failed'+e.message); } } +/** + *@brief Display form for select card to add to action : other_concerned + *action_add_concerned_card + */ +function action_add_concerned_card(obj) +{ + try + { + var dossier = 0; + var inp=""; + var ag_id=0; + + if (obj.dossier) { + dossier = obj.dossier; /* From the button */ + } + if (obj.ag_id) { + ag_id=obj.ag_id; + } + /* from the form */ + if (obj.elements) { + if (obj.elements['gDossier']) + { + dossier = obj.elements['gDossier'].value; + } + + if (obj.elements['query']) { + inp = obj.elements['query'].value; + } + + if (obj.elements['ag_id']) { + ag_id = obj.elements['ag_id'].value; + } + } + if (dossier == 0) { + throw "obj.dossier not found"; + } + if (ag_id == 0) { + throw "obj.ag_id not found"; + } + var query = encodeJSON({ + 'gDossier': dossier, + 'op': 'action_add_concerned_card', + 'query' : inp, + 'ctl' : 'unused', + 'ag_id' : ag_id + }); + + waiting_box(); + + + var action = new Ajax.Request('ajax_card.php', + { + method: 'get', + parameters: query, + onFailure: errorFid, + onSuccess: function (req, txt) + { + try { + console.log(1); + remove_waiting_box(); + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + if (a.length == 0) + { + var rec = req.responseText; + alert('erreur :' + rec); + } + console.log(2); + var html = answer.getElementsByTagName('code'); + console.log(3); + var namectl = a[0].firstChild.nodeValue; + console.log(31); + var nodeXml = html[0]; + console.log(32); + var code_html = getNodeText(nodeXml); + console.log(33); + code_html = unescape_xml(code_html); + console.log(34); + + var sx = 0; + if (window.scrollY) + { + sx = window.scrollY + 40; + } + else + { + sx = document.body.scrollTop + 60; + } + console.log(4); + var div_style = "top:" + sx + "px;height:80%"; + if ( ! $('search_card')) { add_div({id: 'search_card', cssclass: 'inner_box', html: "", style: div_style, drag: true}); } + $('search_card').innerHTML = code_html; + $('query').focus(); + console.log(5); + }catch (e) { + console.log('Erreur ')+e.message; + } + } + } + ); + } + catch (e) + { + alert('search_card failed' + e.message); + return false; + } + return false; +} + /** *@brief when you submit the form for searching a card *@param obj form @@ -176,6 +285,7 @@ function result_card_search(req) { try { + remove_waiting_box(); var answer=req.responseXML; var a=answer.getElementsByTagName('ctl'); @@ -204,6 +314,7 @@ function result_card_search(req) var div_style="top:"+sx+"px;height:80%"; add_div({id:'search_card',cssclass:'inner_box',html:"",style:div_style,drag:true,effect:'blinddown'}); $('search_card').innerHTML=code_html; + $('query').focus(); } catch (e) { @@ -483,7 +594,11 @@ function select_card_type(obj) method:'get', parameters:queryString, onFailure:errorFid, - onSuccess:fill_box + onSuccess:function(req) { + + fill_box(req); + $('lk_cat_card_table').focus(); + } } ); } @@ -724,3 +839,79 @@ try { return false; } } +/*** + * In Follow-up, update, it is possible to add several card as concerned person or company + * this function save it into the database, display the result and remove the search_card div + * @param {type} p_dossier dossier + * @param {type} p_fiche_id fiche.f_id + * @param {type} p_action_id action_gestion.ag_id + * @returns {undefined} nothing + */ +function action_save_concerned(p_dossier, p_fiche_id, p_action_id) { + var query = encodeJSON({'gDossier': p_dossier, 'f_id': p_fiche_id, 'ag_id': p_action_id,'op':'action_save_concerned','ctl':'unused'}); + var a=new Ajax.Request('ajax_card.php', + { + method: 'get', + parameters: query, + onFailure: errorFid, + onSuccess: function (req, txt) + { + try { + console.log(1); + remove_waiting_box(); + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + if (a.length == 0) + { + var rec = req.responseText; + alert('erreur :' + rec); + } + var html = answer.getElementsByTagName('code'); + var namectl = a[0].firstChild.nodeValue; + var nodeXml=html[0]; + var code_html = getNodeText(nodeXml); + code_html = unescape_xml(code_html); + removeDiv('search_card'); + $('concerned_card_td').innerHTML = code_html; + } catch (e) { + console.log('Erreur ') + e.message; + } + } + } + ); + } +function action_remove_concerned(p_dossier,p_fiche_id,p_action_id) +{ + var query = encodeJSON({'gDossier': p_dossier, 'f_id': p_fiche_id, 'ag_id': p_action_id,'op':'action_remove_concerned','ctl':'unused'}); + var a=new Ajax.Request('ajax_card.php', + { + method: 'get', + parameters: query, + onFailure: errorFid, + onSuccess: function (req, txt) + { + try { + console.log(1); + remove_waiting_box(); + var answer = req.responseXML; + var a = answer.getElementsByTagName('ctl'); + if (a.length == 0) + { + var rec = req.responseText; + alert('erreur :' + rec); + } + var html = answer.getElementsByTagName('code'); + var namectl = a[0].firstChild.nodeValue; + var nodeXml=html[0]; + var code_html = getNodeText(nodeXml); + code_html = unescape_xml(code_html); + removeDiv('search_card'); + $('concerned_card_td').innerHTML = code_html; + } catch (e) { + console.log('Erreur ') + e.message; + } + } + } + ); + } + \ No newline at end of file diff --git a/include/ajax_action_remove_concerned.php b/include/ajax_action_remove_concerned.php new file mode 100644 index 000000000..15a412042 --- /dev/null +++ b/include/ajax_action_remove_concerned.php @@ -0,0 +1,46 @@ +remove_linked_card($f_id); +echo $follow->display_linked(); +HtmlInput::button_action_add_concerned_card( $follow->ag_id); + +$response = ob_get_clean(); + +$html = escape_xml($response); +header('Content-type: text/xml; charset=UTF-8'); +echo << + +unused +$html + +EOF; +?> \ No newline at end of file diff --git a/include/ajax_action_save_concerned.php b/include/ajax_action_save_concerned.php new file mode 100644 index 000000000..b8b780e7d --- /dev/null +++ b/include/ajax_action_save_concerned.php @@ -0,0 +1,47 @@ +insert_linked_card($f_id); +/** + * Display all the linked card + */ + +ob_start(); +$follow->display_linked(); +echo HtmlInput::button_action_add_concerned_card( $ag_id); +$response = ob_get_clean(); +$html = escape_xml($response); +header('Content-type: text/xml; charset=UTF-8'); +echo << + +unused +$html + +EOF; +?> \ No newline at end of file diff --git a/include/ajax_add_concerned_card.php b/include/ajax_add_concerned_card.php new file mode 100644 index 000000000..da09c7122 --- /dev/null +++ b/include/ajax_add_concerned_card.php @@ -0,0 +1,83 @@ +'; +$q=new IText('query'); +$q->value=(isset($query))?$query:''; +$r.=''; +$r.=_('Fiche contenant').HtmlInput::infobulle(19); +$r.=$q->input(); +$r.=HtmlInput::submit('fs', _('Recherche'), "", "smallbutton"); +$r.=''; +$r.=dossier::hidden().HtmlInput::hidden('op', 'add_concerned_card'); +$r.=HtmlInput::request_to_hidden(array('ag_id')); +$r.=''; +$query=HtmlInput::default_value_get("query", ""); +$sql_array['query']=$query; +$sql_array['typecard']='all'; + +$fiche=new Fiche($cn); +/* Build the SQL and show result */ +$sql=$fiche->build_sql($sql_array); + + +/* We limit the search to MAX_SEARCH_CARD records */ +$sql=$sql.' order by vw_name limit '.MAX_SEARCH_CARD; +$a=$cn->get_array($sql); +for ($i=0; $i + +unused +$html + +EOF; +?> \ No newline at end of file diff --git a/include/class_follow_up.php b/include/class_follow_up.php index 69b800d4a..eb4e83b8b 100644 --- a/include/class_follow_up.php +++ b/include/class_follow_up.php @@ -165,18 +165,20 @@ class Follow_Up $date = new IDate(); $date->readOnly = $readonly; $date->name = "ag_timestamp"; + $date->id= "ag_timestamp"; $date->value = $this->ag_timestamp; $remind_date = new IDate(); $remind_date->readOnly = $readonly; $remind_date->name = "ag_remind_date"; + $remind_date->id = "ag_remind_date"; $remind_date->value = $this->ag_remind_date; // Doc Type $doc_type = new ISelect(); $doc_type->name = "dt_id"; - $doc_type->value = $this->db->make_array("select dt_id,dt_value from document_type order by dt_value"); + $doc_type->value = $this->db->make_array("select dt_id,dt_value from document_type order by dt_value",1); $doc_type->selected = $this->dt_id; $doc_type->readOnly = $readonly; $str_doc_type = $doc_type->input(); @@ -338,7 +340,8 @@ class Follow_Up $sp->name = 'qcode_dest_label'; $sp->value = $qcode_dest_label; - // contact + // autre - a refaire pour avoir plusieurs fiches + // Sur le modèle des tags $ag_contact = new ICard(); $ag_contact->readOnly = $readonly; $ag_contact->jrn = 0; @@ -1012,7 +1015,7 @@ class Follow_Up function fromArray($p_array) { global $g_user; - $this->ag_id = (isset($p_array['ag_id'])) ? $p_array['ag_id'] : ""; + $this->ag_id = (isset($p_array['ag_id'])) ? $p_array['ag_id'] : 0; $this->ag_ref = (isset($p_array['ag_ref'])) ? $p_array['ag_ref'] : ""; $this->qcode_dest = (isset($p_array['qcode_dest'])) ? $p_array['qcode_dest'] : ""; $this->f_id_dest = (isset($p_array['f_id_dest'])) ? $p_array['f_id_dest'] : 0; @@ -1311,7 +1314,7 @@ class Follow_Up if ($fiche->id == 0) $str = ' and false '; else - $str = " and (f_id_dest= " . $fiche->id . " ) "; + $str = " and (f_id_dest= " . $fiche->id . " or ag_id in (select ag_id from action_person as ap where ap.f_id=". $fiche->id .") )"; } } if (isset($tdoc) && $tdoc != -1) @@ -1531,7 +1534,7 @@ class Follow_Up $a_tag[$e]['t_id']); echo ''; echo $a_tag[$e]['t_tag']; - echo HtmlInput::anchor( " ⵝ ", "javascript:void(0)", $js_remove, ' class="smallbutton " style="padding:0px;display:inline" '); + echo HtmlInput::anchor( " ⵝ ", "javascript:void(0)", $js_remove, ' class="smallbutton" style="padding:0px;display:inline" '); echo ''; echo ' '; echo ' '; @@ -1623,4 +1626,72 @@ class Follow_Up array($mag_id[$i])); } } + /** + * Verify that data are correct + * @throws Exception + */ + function verify() + { + if ( $this->dt_id == -1 ) { + throw new Exception (_('Type action invalide'),10); + } + if ( isDate($this->ag_timestamp) != $this->ag_timestamp ) + throw new Exception (_('Date invalide'),20); + if ( isDate($this->ag_remind_date) != $this->ag_remind_date ) + throw new Exception (_('Date invalide'),30); + } + /** + * Add another concerned (tiers, supplier...) + * @global type $g_user + * @param type $p_fiche_id + */ + function insert_linked_card($p_fiche_id) + { + global $g_user; + if ( $g_user->can_write_action($this->ag_id)) { + /** + * insert into action_person + */ + $count=$this->db->get_value('select count(*) from action_person where f_id=$1 and ag_id=$2',array($p_fiche_id,$this->ag_id)); + if ( $count == 0 ) + { + $this->db->exec_sql('insert into action_person (ag_id,f_id) values ($1,$2)',array($this->ag_id,$p_fiche_id)); + } + } + } + /** + * Remove another concerned (tiers, supplier...) + * @global type $g_user + * @param type $p_fiche_id + */ + function remove_linked_card($p_fiche_id) + { + global $g_user; + if ( $g_user->can_write_action($this->ag_id)) { + $this->db->exec_sql('delete from action_person where ag_id = $1 and f_id = $2',array($this->ag_id,$p_fiche_id)); + } + + } + /** + * Display the other concerned (tiers, supplier...) + * @return string + */ + function display_linked() + { + $a_linked=$this->db->get_array('select ap_id,f_id from action_person where ag_id=$1',array($this->ag_id)); + if ( count($a_linked) == 0 ) return ""; + for ($i=0;$idb,$a_linked[$i]['f_id']); + $qc=$fiche->get_quick_code(); + $js_remove=sprintf("onclick=\"action_remove_concerned('%s','%s','%s')\"",dossier::id(), + $a_linked[$i]['f_id'],$this->ag_id); + echo ''; + echo $qc; + echo HtmlInput::anchor( " ⵝ ", "javascript:void(0)", $js_remove, ' class="smallbutton" style="padding:0px;display:inline" '); + echo ''; + echo ' '; + echo ' '; + } + } } diff --git a/include/class_html_input.php b/include/class_html_input.php index aa473b34a..202846b21 100755 --- a/include/class_html_input.php +++ b/include/class_html_input.php @@ -878,7 +878,16 @@ class HtmlInput $rmOperation=sprintf("javascript:if ( confirm('"._('Voulez-vous effacer cette relation ')."')==true ) {remove_operation('%s','%s');}", dossier::id(), $p_operation); - $js= ''."ⵝ".''; + $js= ''."ⵝ".''; + return $js; + } + static function button_action_add_concerned_card($p_agid) + { + $dossier=Dossier::id(); + $javascript= << - + diff --git a/include/template/detail-action.php b/include/template/detail-action.php index 461157ad8..d96c7c3b2 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -1,24 +1,17 @@
- - - -
- -
+?>

input(); ?>

-
+
- +
- @@ -31,7 +24,63 @@ ?> + + + + + + + + + + + + + + + + + ag_id > 0 ): ?> + + + + + + +
+ ag_id;?>
+ + + +
+ + + search().$w->input(); + ?> +
+ + + search().$ag_contact->input(); + ?> +
+ input(); ?> +
+ + + display_linked(); + echo HtmlInput::button_action_add_concerned_card( $this->ag_id)?> + + +
+ + +
+
+ + + @@ -59,47 +108,6 @@ ?> - - - - - - - - - - - - -
- - - search().$w->input(); - ?> -
- - - search().$ag_contact->input(); - ?> -
- input(); ?> -
- - -
-
- - - - - - -
- - - -
@@ -143,9 +151,9 @@
-
-
-

Opérations concernées

+
+
+

Opérations concernées

    '.$iconcerned->input().'';?>
-
+

    @@ -183,7 +191,7 @@ dossier::id(), $action[$o]['ag_id'],$_REQUEST['ag_id']); $showAction=''; - $js= ''._("Effacer").''; + $js= ''; echo '
  1. '.$showAction.$action[$o]['str_date']." ".$action[$o]['ag_ref']." ". h($action[$o]['sub_title']).'('.h($action[$o]['dt_value']).')'." " .$js.'
  2. '; @@ -199,8 +207,9 @@
'.$iaction->input().'';?>
-
-
+
+
+

@@ -220,23 +229,30 @@ function small(p_id_textarea){ Document créé le ag_timestamp ?> par ag_owner?> -

-

+

+

input(); ?>

-

+

+ + Effacer'; + $js= ''; echo hb('n°'.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." ".$acomment[$c]['str_agc_date'].')').$js. '
 '.
 				" ".h($acomment[$c]['agc_comment']).'
' @@ -265,6 +281,7 @@ echo '';
+ -
- +
+ - +
- -
+
-
-
0.0 -
0.0 -
0.0 +
+
0.0 +
0.0 +
0.0
-
+

Total HTVA
Total TVA
Total TVAC
-
+
">
@@ -359,7 +377,7 @@ function toggleShowDetail() {
ag_id != 0 && ! $readonly) : ?> -
+

Dossier::id(),'ag_id'=>$this->ag_id,'create_invoice'=>1,'ac'=>$menu->get('code_invoice'))); @@ -369,23 +387,23 @@ function toggleShowDetail() {

-
+
- +
-
+
+ -
+
@@ -464,6 +482,6 @@ catch(exception) { alert('
-
+ \ No newline at end of file diff --git a/sql/upgrade.sql b/sql/upgrade.sql index f236c2fbe..f32de1e05 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -57,9 +57,27 @@ create table key_distribution_activity ); comment on table key_distribution is 'Distribution key for analytic'; -comment on table key_distribution_ledger is 'Legder where the distribution key can be used' ; -comment on table key_distribution_detail is 'Row of activity and percent'; comment on table key_distribution_activity is 'activity (account) linked to the row'; +comment on column key_distribution.kd_id is 'PK'; +comment on column key_distribution.kd_name is 'Name of the key'; +comment on column key_distribution.kd_description is 'Description of the key'; + +comment on table key_distribution_ledger is 'Legder where the distribution key can be used' ; +comment on column key_distribution_ledger.kl_id is 'pk'; +comment on column key_distribution_ledger.kd_id is 'fk to key_distribution'; +comment on column key_distribution_ledger.jrn_def_id is 'fk to jrnd_def, ledger where this key is available'; + + +comment on table key_distribution_detail is 'Row of activity and percent'; +comment on column key_distribution_detail.ke_id is 'pk'; +comment on column key_distribution_detail.kd_id is 'fk to key_distribution'; +comment on column key_distribution_detail.ke_row is 'group order'; + +comment on table key_distribution_activity is 'Contains the analytic account'; +comment on column key_distribution_activity.ka_id is 'pk'; +comment on column key_distribution_activity.ke_id is 'fk to key_distribution_detail'; +comment on column key_distribution_activity.po_id is 'fk to poste_analytique'; +comment on column key_distribution_activity.pa_id is 'fk to plan_analytique'; drop view vw_fiche_attr cascade; @@ -155,9 +173,14 @@ create index jrnx_j_qcode_ix on jrnx (j_qcode); CREATE TABLE action_person ( ap_id SERIAL NOT NULL, - ag_id int4 NOT NULL, -f_id int4, PRIMARY KEY (ap_id)); + ag_id int4 NOT NULL references action_gestion(ag_id) on update cascade on delete cascade,, + f_id int4 not null references fiche(f_id) on update cascade on delete cascade, + PRIMARY KEY (ap_id)); + COMMENT ON TABLE action_person IS 'Person involved in the action'; +comment on column action_person.ap_id is 'pk'; +comment on column action_person.ag_id is 'fk to action_action'; +comment on column action_person.ag_id is 'fk to fiche'; ALTER TABLE action_person ADD CONSTRAINT action_gestion_ag_id_fk2 FOREIGN KEY (ag_id) REFERENCES action_gestion (ag_id); ALTER TABLE action_person ADD CONSTRAINT fiche_f_id_fk2 FOREIGN KEY (f_id) REFERENCES fiche(f_id); @@ -184,4 +207,6 @@ CREATE TRIGGER trg_category_card_before_delete BEFORE delete ON fiche_def FOR EACH ROW - EXECUTE PROCEDURE comptaproc.category_card_before_delete(); \ No newline at end of file + EXECUTE PROCEDURE comptaproc.category_card_before_delete(); + +alter table action_gestion add constraint fk_action_gestion_document_type foreign key (ag_type) references document_type(dt_id); diff --git a/unit-test/include/class_acc_ledger_soldTest.php b/unit-test/include/class_acc_ledger_soldTest.php index 66908f94c..40ded15e4 100644 --- a/unit-test/include/class_acc_ledger_soldTest.php +++ b/unit-test/include/class_acc_ledger_soldTest.php @@ -19,7 +19,7 @@ class Acc_Ledger_SoldTest extends PHPUnit_Framework_TestCase protected function setUp() { include 'global.php'; - $this->object=new Acc_Ledger_Sold($g_connection,2); + $this->object=new Acc_Ledger_Sold($g_connection, 2); } /** @@ -38,7 +38,7 @@ class Acc_Ledger_SoldTest extends PHPUnit_Framework_TestCase */ public function testVerify() { - $this->object->verify(array()); + $this->object->verify(array()); } /** @@ -69,7 +69,8 @@ class Acc_Ledger_SoldTest extends PHPUnit_Framework_TestCase public function testExtra_info() { $info=$this->object->extra_info(); - if ( ! is_string($info) ) { + if (!is_string($info)) + { $this->assertTrue(FALSE); } } @@ -93,8 +94,9 @@ class Acc_Ledger_SoldTest extends PHPUnit_Framework_TestCase public function testInput() { $_REQUEST['ac']='VEN'; - $info=$this->object->input(); - if ( ! is_string($info) ) { + $info=$this->object->input(); + if (!is_string($info)) + { $this->assertTrue(FALSE); } } @@ -123,16 +125,4 @@ class Acc_Ledger_SoldTest extends PHPUnit_Framework_TestCase ); } - /** - * @covers Acc_Ledger_Sold::test_me - * @todo Implement testTest_me(). - */ - public function testTest_me() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - }