diff --git a/include/category_detail.inc.php b/include/category_detail.inc.php index b13c91292..e3380bc55 100644 --- a/include/category_detail.inc.php +++ b/include/category_detail.inc.php @@ -52,6 +52,7 @@ if ( ! $p_readonly) echo '
'; echo dossier::hidden(); echo HtmlInput::hidden('sb','detail'); echo HtmlInput::hidden('dc','cc'); +$supplier->setDisplayMode("large"); echo $supplier->Display($p_readonly); $w=new IHidden(); $w->name="p_action"; @@ -59,6 +60,7 @@ $w->value="supplier"; echo $w->input(); $w->name="f_id"; $w->value=$f_id; + echo $w->input(); echo HtmlInput::hidden('action_fiche',''); if ( ! $p_readonly) diff --git a/include/cfgfiche.inc.php b/include/cfgfiche.inc.php index bd44c731b..7e45027b6 100644 --- a/include/cfgfiche.inc.php +++ b/include/cfgfiche.inc.php @@ -91,7 +91,8 @@ if ( isset ($_POST['change_name'])) if (isset ($_REQUEST['label']) ) { $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']); - $fiche_def->SaveLabel($_REQUEST['label']); + $label=$http->request("label"); + $fiche_def->SaveLabel($label); if ( isset($_REQUEST['create'])) { $fiche_def->set_autocreate(true); @@ -100,8 +101,8 @@ if ( isset ($_POST['change_name'])) { $fiche_def->set_autocreate(false); } - $fiche_def->save_class_base($_REQUEST['class_base']); - $fiche_def->save_description($_REQUEST['fd_description']); + $fiche_def->save_class_base($http->request('class_base')); + $fiche_def->save_description($http->request('fd_description')); } echo $fiche_def->input_detail(); diff --git a/include/class/card_attribut_mtable.class.php b/include/class/card_attribut_mtable.class.php index ab928136c..26c5be1c2 100644 --- a/include/class/card_attribut_mtable.class.php +++ b/include/class/card_attribut_mtable.class.php @@ -40,7 +40,8 @@ class Card_Attribut_MTable extends Manage_Table_SQL $this->set_property_updatable("ad_id", FALSE); $this->set_col_label("ad_text", _("Nom")); $this->set_col_label("ad_type", _("Type")); - $this->set_col_label('ad_size', _("Taille")); + $this->set_col_label("ad_size", _("Taille")); + $this->set_col_label('ad_default_order', _("Ordre")); $this->set_col_label("ad_extra", _("Option sup.")); $this->set_col_label("ad_search_followup", _("Recherche suivi")); @@ -62,6 +63,7 @@ class Card_Attribut_MTable extends Manage_Table_SQL $this->set_col_tips("ad_search_followup", 77); // to prevent a call to this function for each row $this->dossier_id=Dossier::id(); + $this->set_order(['ad_id','ad_text',"ad_type","ad_default_order","ad_size","ad_extra","ad_search_followup"]); $this->set_col_sort(1); } @@ -217,6 +219,9 @@ class Card_Attribut_MTable extends Manage_Table_SQL $this->set_error("ad_extra", _("La requête SQL doit commencer par SELECT ")); } } + if ( $object_sql->ad_default_order < 11 || $object->ad_default_order > 9998) { + $this->set_error("ad_default_order",_("Valeur entre 11 et 9998")); + } if ($this->count_error()>0) { return false; diff --git a/include/class/card_property.class.php b/include/class/card_property.class.php index 77b230122..acb748b3d 100644 --- a/include/class/card_property.class.php +++ b/include/class/card_property.class.php @@ -48,11 +48,25 @@ class Card_Property //!< jnt_order order to display var $cn; //!< cn database connexion - + protected $display_mode; + //!< display mode determine if there link function __construct($cn, $ad_id=0) { $this->cn=$cn; $this->ad_id=0; + $this->display_mode='window'; + } + public function setDisplayMode($p_mode) + { + if ( ! in_array($p_mode,array("window","large"))) { + throw new Exception("FIC70 invalide display mode"); + } + $this->display_mode=$p_mode; + return $this; + } + public function getDisplayMode() + { + return $this->display_mode; } public function get_ad_id() @@ -351,7 +365,10 @@ class Card_Property { $class="input_text"; } - $r.="".td(_($w->label)." $bulle", ' class="'.$class.'" ').td($w->input()." $msg")." "; + $url=''.$this->add_link($this->ad_id,$this->av_text).''; + $r.="".td(_($w->label)." $bulle", ' class="'.$class.'" ').td($w->input()." $msg"). + $url. + " "; return $r; } @@ -405,8 +422,9 @@ class Card_Property default: $w->value=$this->av_text; } + $url="".$this->add_link($this->ad_id,$this->av_text).''; $ret.="".td(_($this->ad_text)." $bulle", ' class="'.$class.'" ').td($value." $msg", - 'style="border:1px solid blue"')." "; + 'style="border:1px solid blue"').''.$url.''." "; return $ret; } @@ -616,5 +634,23 @@ class Card_Property return; } + /** + * @brief add a link + * @param $p_ad_id + * @param $p_text + * @return false|mixed|string + */ + private function add_link($p_ad_id,$p_text) { + if ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_WEBSITE) { + $url=linkTo($p_text); + }elseif ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_EMAIL) { + $url=mailTo($p_text); + }elseif ( $this->display_mode=="large" && $p_ad_id == ATTR_DEF_FAX) { + $url=faxTo($p_text); + }else { + return ""; + } + return $url; + } } diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index c6a9ca2a1..a391b35ae 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -44,6 +44,7 @@ class Fiche var $row; /*! < All the row from the ledgers */ var $quick_code; /*!< quick_code of the card */ private $f_enable; /*!< if card is enable (fiche.f_enable) */ + private $display_mode ; /*!< how the card is displaid */ function __construct($p_cn,$p_id=0) { $this->cn=$p_cn; @@ -62,7 +63,29 @@ class Fiche $this->fiche_def=0; } - + $this->display_mode="window"; + } + + /** + * @brief how the card is display : either in a window or a greated container + * @param string $p_mode can be large or window + * @return Fiche + * @throws Exception + */ + function setDisplayMode($p_mode) { + if ( ! in_array($p_mode,array("window","large"))) { + throw new Exception("FIC70 invalide display mode"); + } + $this->display_mode=$p_mode; + return $this; + } + + /** + * @return string + */ + public function getDisplayMode(): string + { + return $this->display_mode; } public function set_fiche_def($p_fiche_def) { @@ -380,6 +403,7 @@ class Fiche { $msg=""; $bulle=""; + $r->setDisplayMode($this->display_mode); if ($p_readonly) { $ret .= $r->print(); @@ -1268,7 +1292,7 @@ class Fiche $bank=new Acc_Parm_Code($this->cn,'BANQUE'); $cash=new Acc_Parm_Code($this->cn,'CAISSE'); $cc=new Acc_Parm_Code($this->cn,'COMPTE_COURANT'); - + bcscale(4); $gDossier=dossier::id(); $p_search=sql_string($p_search); @@ -1306,17 +1330,18 @@ class Fiche } // Get The result Array $step_tiers=$this->get_by_category($offset,$search.$filter_amount,'name'); - + if ( $all_tiers == 0 || empty($step_tiers ) ) { return ""; } $r=""; $r.=$bar; - + $r.=''. ''. ' + '; @@ -1329,7 +1354,7 @@ class Fiche foreach ($step_tiers as $tiers ) { $i++; - + /* Filter on the default year */ $amount=$tiers->get_solde_detail($filter_year); @@ -1339,8 +1364,8 @@ class Fiche $odd=""; $odd = ($i % 2 == 0 ) ? ' odd ': ' even '; $accounting=$tiers->strAttribut(ATTR_DEF_ACCOUNT); - if ( ! empty($accounting) && $p_action == 'bank' - && $amount['debit'] < $amount['credit'] + if ( ! empty($accounting) && $p_action == 'bank' + && $amount['debit'] < $amount['credit'] && ( /** the accounting is a financial account *****/ (!empty ($bank->value) && strpos($accounting,$bank->p_value)===0 ) @@ -1352,9 +1377,9 @@ class Fiche //put in red if c>d $odd.=" notice "; } - + $odd=' class="'.$odd.'"'; - + $r.=""; $url_detail=$script.'?'.http_build_query(array('sb'=>'detail','sc'=>'sv','ac'=>$_REQUEST['ac'],'f_id'=>$tiers->id,'gDossier'=>$gDossier)); $e=sprintf(' ', @@ -1367,6 +1392,7 @@ class Fiche " ".$tiers->strAttribut(ATTR_DEF_CP). " ".$tiers->strAttribut(ATTR_DEF_PAYS)). ""; + $r.=''; $str_deb=(($amount['debit']==0)?0:nbm($amount['debit'])); $str_cred=(($amount['credit']==0)?0:nbm($amount['credit'])); $str_solde=nbm($amount['solde']); diff --git a/include/class/fiche_def.class.php b/include/class/fiche_def.class.php index 4c751bbd2..f087bc505 100644 --- a/include/class/fiche_def.class.php +++ b/include/class/fiche_def.class.php @@ -295,20 +295,18 @@ $order if (sizeof($def_attr) != 0 ) { // insert all the mandatory fields into jnt_fiche_attr - $jnt_order=10; - foreach ( $def_attr as $i=>$v) + foreach ( $def_attr as $row) { - $order=$jnt_order; - if ( $v['ad_id'] == ATTR_DEF_NAME ) + $order=$row['ad_default_order']; + if ( $row['ad_id'] == ATTR_DEF_NAME ) $order=0; - $count=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1 and ad_id=$2",array($fd_id,$v['ad_id'])); + $count=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1 and ad_id=$2",array($fd_id,$row['ad_id'])); if ($count == 0) { $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id,jnt_order) values (%d,%s,%d)", - $fd_id,$v['ad_id'],$order); + $fd_id,$row['ad_id'],$order); $this->cn->exec_sql($sql); - $jnt_order+=10; } } } @@ -664,7 +662,7 @@ $order /*!\brief save the order of a card, update the column jnt_fic_attr.jnt_order *\param $p_array containing the order */ - function save_order($p_array) + function jntsave_order($p_array) { extract($p_array, EXTR_SKIP); $this->GetAttribut(); @@ -734,10 +732,11 @@ $order { // find the min attr for the fiche_def_ref - $Sql="select ad_id,ad_text from attr_min natural join attr_def + $Sql="select ad_id,ad_text ,ad_default_order + from attr_min natural join attr_def natural join fiche_def_ref where - frd_id= $1"; + frd_id= $1 order by ad_default_order"; $Res=$this->cn->exec_sql($Sql,array($p_fiche_def_ref)); $Num=Database::num_row($Res); @@ -750,6 +749,7 @@ $order $f=Database::fetch_array($Res,$i); $array[$i]['ad_id']=$f['ad_id']; $array[$i]['ad_text']=$f['ad_text']; + $array[$i]['ad_default_order']=$f['ad_default_order']; } return $array; } diff --git a/include/constant.php b/include/constant.php index 849ae0872..9a3da9063 100644 --- a/include/constant.php +++ b/include/constant.php @@ -115,7 +115,7 @@ if (!defined("NOALYSS_PACKAGE_REPOSITORY")) { if (!defined("SYSINFO_DISPLAY")) { define("SYSINFO_DISPLAY", TRUE); } -define("DBVERSION", 178); +define("DBVERSION", 179); define("MONO_DATABASE", 25); define("DBVERSIONREPO", 20); define('NOTFOUND', '--not found--'); @@ -225,6 +225,7 @@ define("ATTR_DEF_TVA_NON_DEDUCTIBLE", 21); define("ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP", 22); define("ATTR_DEF_QUICKCODE", 23); define("ATTR_DEF_FIRST_NAME", 32); +define("ATTR_DEF_WEBSITE", 34); define('ATTR_DEF_ACCOUNT_ND_TVA', 50); define('ATTR_DEF_ACCOUNT_ND_TVA_ND', 51); diff --git a/include/database/attr_def_sql.class.php b/include/database/attr_def_sql.class.php index 94cd45e19..9c71022aa 100644 --- a/include/database/attr_def_sql.class.php +++ b/include/database/attr_def_sql.class.php @@ -46,6 +46,7 @@ class Attr_Def_SQL extends Table_Data_SQL , "ad_size"=>"ad_size" , "ad_extra"=>"ad_extra" , "ad_search_followup"=>"ad_search_followup" + ,"ad_default_order"=>"ad_default_order" ); /* * Type of columns @@ -57,6 +58,7 @@ class Attr_Def_SQL extends Table_Data_SQL , "ad_size"=>"text" , "ad_extra"=>"text" , "ad_search_followup"=>"numeric" + , "ad_default_order"=>"numeric" ); diff --git a/include/sql/patch/upgrade178.sql b/include/sql/patch/upgrade178.sql new file mode 100644 index 000000000..4682ffd78 --- /dev/null +++ b/include/sql/patch/upgrade178.sql @@ -0,0 +1,112 @@ +begin; +update menu_ref set me_menu='Catégorie fiche' where me_code='CCARD'; +alter table attr_def add column ad_default_order int; +comment on column attr_def.ad_default_order is 'Default order of the attribute'; + + + + + + + + +delete from attr_min where ad_id=30 and frd_id=2; +insert into attr_min (frd_id,ad_id) values (2,5); +insert into attr_min (frd_id,ad_id) values (3,5); + + +insert into attr_min (frd_id,ad_id) values (3,5) on conflict (frd_id ,ad_id ) do nothing; + +insert into attr_min (frd_id,ad_id) values (14,9) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,12) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,14) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,16) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,17) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,18) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,24) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,26) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (14,5) on conflict (frd_id ,ad_id ) do nothing; + +insert into attr_min (frd_id,ad_id) values (25,14) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (25,32) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (25,27) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (25,18) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (25,27) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (25,32) on conflict (frd_id ,ad_id ) do nothing; + +insert into attr_min (frd_id,ad_id) values (13,5) on conflict (frd_id ,ad_id ) do nothing; + +insert into attr_min (frd_id,ad_id) values (8,5) on conflict (frd_id ,ad_id ) do nothing; + + +insert into attr_min (frd_id,ad_id) values (7,5) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (7,11) on conflict (frd_id ,ad_id ) do nothing; + + +insert into attr_min (frd_id,ad_id) values (6,5) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (6,9) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (6,25) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (6,33) on conflict (frd_id ,ad_id ) do nothing; + +delete from attr_min where frd_id =10 and ad_id =12; + +insert into attr_min (frd_id,ad_id) values (10,5) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (10,9) on conflict (frd_id ,ad_id ) do nothing; + +delete from attr_min where frd_id =12 and ad_id =12; + +insert into attr_min (frd_id,ad_id) values (12,5) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (12,9) on conflict (frd_id ,ad_id ) do nothing; + +delete from attr_min where frd_id =4 and ad_id =4; +insert into attr_min (frd_id,ad_id) values (4,5) on conflict (frd_id ,ad_id ) do nothing; +insert into attr_min (frd_id,ad_id) values (4,26) on conflict (frd_id ,ad_id ) do nothing;; + +delete from attr_min where frd_id =1 and ad_id =15; +insert into attr_min (frd_id,ad_id) values (1,5) on conflict (frd_id ,ad_id ) do nothing; + +insert into attr_def values (34,'Site Web','text',22,null,1,157); +insert into attr_min values(8,34), (9,34),(14,34),(4,34); + +-- select 'update attr_def set ad_default_order = '||ad_default_order::text||' where ad_id='||ad_id::text||';' from attr_def ad order by ad_default_order; +update attr_def set ad_default_order = 10 where ad_id=1; +update attr_def set ad_default_order = 20 where ad_id=32; +update attr_def set ad_default_order = 30 where ad_id=9; +update attr_def set ad_default_order = 40 where ad_id=34; +update attr_def set ad_default_order = 50 where ad_id=30; +update attr_def set ad_default_order = 60 where ad_id=12; +update attr_def set ad_default_order = 70 where ad_id=25; +update attr_def set ad_default_order = 80 where ad_id=13; +update attr_def set ad_default_order = 90 where ad_id=18; +update attr_def set ad_default_order = 100 where ad_id=27; +update attr_def set ad_default_order = 110 where ad_id=17; +update attr_def set ad_default_order = 120 where ad_id=26; +update attr_def set ad_default_order = 130 where ad_id=14; +update attr_def set ad_default_order = 140 where ad_id=15; +update attr_def set ad_default_order = 150 where ad_id=16; +update attr_def set ad_default_order = 160 where ad_id=24; +update attr_def set ad_default_order = 170 where ad_id=4; +update attr_def set ad_default_order = 180 where ad_id=3; +update attr_def set ad_default_order = 190 where ad_id=5; +update attr_def set ad_default_order = 200 where ad_id=6; +update attr_def set ad_default_order = 210 where ad_id=7; +update attr_def set ad_default_order = 220 where ad_id=2; +update attr_def set ad_default_order = 230 where ad_id=8; +update attr_def set ad_default_order = 240 where ad_id=11; +update attr_def set ad_default_order = 250 where ad_id=10; +update attr_def set ad_default_order = 260 where ad_id=33; +update attr_def set ad_default_order = 270 where ad_id=19; +update attr_def set ad_default_order = 280 where ad_id=20; +update attr_def set ad_default_order = 290 where ad_id=53; +update attr_def set ad_default_order = 300 where ad_id=21; +update attr_def set ad_default_order = 310 where ad_id=51; +update attr_def set ad_default_order = 320 where ad_id=22; +update attr_def set ad_default_order = 330 where ad_id=50; +update attr_def set ad_default_order = 340 where ad_id=52; +update attr_def set ad_default_order = 350 where ad_id=31; +update attr_def set ad_default_order = 9999 where ad_id=23; + + + +insert into version (val,v_description) values (179,'Improve Card Attribut - default order'); +commit; \ No newline at end of file diff --git a/sql/upgrade.sql b/sql/upgrade.sql index e69de29bb..8b1378917 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -0,0 +1 @@ + diff --git a/unit-test/include/class/acc_ledgerTest.php b/unit-test/include/class/acc_ledgerTest.php index 3d37fe5f1..61087b87a 100644 --- a/unit-test/include/class/acc_ledgerTest.php +++ b/unit-test/include/class/acc_ledgerTest.php @@ -847,6 +847,7 @@ class Acc_LedgerTest extends TestCase $this->object->set_ledger_id(4); $this->object->input_new(); $result=ob_get_contents(); + ob_end_clean(); \Noalyss\Facility::save_file(__DIR__."/file", "acc_ledger-input_new.html", $result); $size=filesize(__DIR__."/file/acc_ledger-input_new.html"); diff --git a/unit-test/include/class/card_propertyTest.php b/unit-test/include/class/card_propertyTest.php index 496047319..48f82bd20 100644 --- a/unit-test/include/class/card_propertyTest.php +++ b/unit-test/include/class/card_propertyTest.php @@ -206,7 +206,7 @@ class Card_PropertyTest extends TestCase global $g_connection; $fiche=$this->getFiche(); Card_Property::load($fiche); - $this->assertEquals(count($fiche->attribut), 35, 'there are not 35 attributes'); + $this->assertEquals(count($fiche->attribut), 36, 'there are not 36 attributes'); $fiche=new Fiche($g_connection); Card_Property::load($fiche); $this->assertTrue(empty($fiche->attribut),'Card property must be equals to 0 (unknown category ');
'._('Quick Code').Icon_Action::infobulle(17).''._('Poste comptable').''._('Nom').''.' '._('Adresse').''._('site web').' '._('Total débit').' '._('Total crédit').' '._('Solde').'
'.linkTo($tiers->strAttribut(ATTR_DEF_WEBSITE,0)).'