diff --git a/html/install.php b/html/install.php index 513c8b982..6ac3d2be3 100644 --- a/html/install.php +++ b/html/install.php @@ -352,8 +352,8 @@ if (!defined('PHP_VERSION_ID')) { define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); } -if ( PHP_VERSION_ID < 50500) { - echo $g_failed. " ".phpversion." ". _("Version PHP trop basse , minimum 5.4"); +if ( PHP_VERSION_ID < 70033) { + echo $g_failed. " ".phpversion." ". _("Version PHP trop basse , minimum 7.0.33"); } else { echo $g_succeed. " ".phpversion(); @@ -456,10 +456,10 @@ $version=$cn->get_value($sql); echo _("Version base de données :"),$version; $majeur=explode(".",$version); -if ( $majeur[0] < 9 ) +if ( $majeur[0] < 9 && $majeur[0] < 5 ) { ?> -

diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 3bea3bfe1..cfc61d27b 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -346,6 +346,22 @@ function ledger_fin_add_row() nb.value++; } +/** + * Add multiple row + * @param p_numrow + */ +function ledger_add_multiple(p_elid) +{ + var nbrow=$(p_elid).value; + if (nbrow == NaN) {nbrow=1;} + var type_ledger=$(p_elid+"_ledger").value; + var i=0; + for (i=0;icheck_action(FICCAT)==0)exit(); - ob_start(); - if( ! isset($_GET['ad_id']) || isNumber($_GET['ad_id']) ==0) - throw new Exception ( _("Parametre ad_id est invalide"),11); - $ad_id= $_GET['ad_id']; + + ob_start(); try { + $ad_id= $http->get("ad_id","number"); $cn->start(); $fa=new Fiche_Attr($cn,$ad_id); $fa->delete(); @@ -117,6 +117,7 @@ case 'rmfa': catch (Exception $e) { $cn->rollback(); + record_log($e->getMessage()); record_log($e->getTraceAsString()); echo $e->getMessage(); } diff --git a/include/class/acc_balance.class.php b/include/class/acc_balance.class.php index 6fbf2fc36..71469ab72 100644 --- a/include/class/acc_balance.class.php +++ b/include/class/acc_balance.class.php @@ -273,11 +273,10 @@ class Acc_Balance // Add the saldo $i+=1; $delta=bcsub($tot_deb,$tot_cred); - $side_delta=($delta<0)?"C":"D"; - $side_delta=($delta==0)?"=":$side_delta; - + $side_delta=findSide($delta); + $a['poste']=""; - $a['label']="Totaux ".nbm(abs($delta)).$side_delta; + $a['label']=sprintf(_("Totaux %s %s"),nbm(abs($delta)),$side_delta); $a['sum_deb']=$tot_deb; $a['sum_cred']=$tot_cred; $a['solde_deb']=$tot_deb_saldo; diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index 8bf4f5032..b6a068262 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -50,6 +50,7 @@ require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_currency.class.php'; require_once NOALYSS_INCLUDE.'/database/operation_currency_sql.class.php'; require_once NOALYSS_INCLUDE.'/class/pre_op_ods.class.php'; +require_once NOALYSS_INCLUDE.'/class/html_input_noalyss.class.php'; /** \file * @brief Class for jrn, class acc_ledger for manipulating the ledger diff --git a/include/class/acc_ledger_purchase.class.php b/include/class/acc_ledger_purchase.class.php index 81ca78428..de2758b4e 100644 --- a/include/class/acc_ledger_purchase.class.php +++ b/include/class/acc_ledger_purchase.class.php @@ -1443,7 +1443,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger // Set correctly the REQUEST param for jrn_type $r.= HtmlInput::hidden('jrn_type','ACH'); - $r.= HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_add_row()"'); + $r.= Html_Input_Noalyss::ledger_add_item("O"); diff --git a/include/class/acc_ledger_sold.class.php b/include/class/acc_ledger_sold.class.php index b4c807738..81426e67b 100644 --- a/include/class/acc_ledger_sold.class.php +++ b/include/class/acc_ledger_sold.class.php @@ -1508,8 +1508,7 @@ EOF; // Set correctly the REQUEST param for jrn_type $r.=HtmlInput::hidden('jrn_type', 'VEN'); - - $r.=HtmlInput::button('add_item', _('Ajout article'), ' onClick="ledger_add_row()"'); + $r.= Html_Input_Noalyss::ledger_add_item("O"); $r.= create_script("$('" . $Date->id . "').focus()"); return $r; } diff --git a/include/class/acc_plan_mtable.class.php b/include/class/acc_plan_mtable.class.php index 9f37cbcb8..b5537e957 100644 --- a/include/class/acc_plan_mtable.class.php +++ b/include/class/acc_plan_mtable.class.php @@ -62,21 +62,24 @@ class Acc_Plan_MTable extends Manage_Table_SQL ["label"=>_("Produit inversé"),"value"=>"PROINV"], ["label"=>_("Contexte"),"value"=>"CON"] ]); - $this->set_col_type("pcm_direct_use", "select",array(["label"=>_("Oui"),"value"=>"Y"],["label"=>"Non","value"=>"N"])); - $this->a_order=["pcm_val","pcm_lib","parent_accounting","pcm_direct_use","pcm_type","fiche_qcode"]; + $this->set_col_type("pcm_direct_use", "select", + array(["label" => _("Oui"), "value" => "Y"], ["label" => "Non", "value" => "N"])); + $this->set_col_type("pcm_val", "custom"); + $this->a_order = ["pcm_val", "pcm_lib", "parent_accounting", "pcm_direct_use", "pcm_type", "fiche_qcode"]; $this->set_icon_mod("first"); } + /** * Display a row * @param type $p_row array of value key column=>value */ function display_row($p_row) { - printf('', + printf('', $this->object_name, $p_row[$this->table->primary_key]) ; - + $dossier_id=Dossier::id(); $nb_order=count($this->a_order); for ($i=0; $i<$nb_order; $i++) @@ -99,29 +102,29 @@ class Acc_Plan_MTable extends Manage_Table_SQL elseif ($v == "fiche_qcode") { $count=$this->table->cn->get_value("select count(*) from fiche_detail where ad_id=5 and ad_value=$1",array($p_row['pcm_val'])); if ($count == 0) echo td(""); - elseif ($count == 1 ) { + elseif ($count == 1 ) { echo ''; - echo HtmlInput::card_detail($p_row[$v]) ; + echo HtmlInput::card_detail($p_row[$v]) ; echo ''; - + } - elseif ($count > 1) { + elseif ($count > 1) { echo ''; $a_code=explode(",",$p_row[$v]); $nb_code=count($a_code); for ($xx = 0;$xx < $nb_code;$xx++) { - echo HtmlInput::card_detail($a_code[$xx])."," ; + echo HtmlInput::card_detail($a_code[$xx])."," ; } echo " ($count) "; echo Icon_Action::more(uniqid(), sprintf("display_all_card('%s','%s')",$dossier_id,$p_row["pcm_val"])); echo ''; - - } + + } } elseif ($v=="pcm_lib") { - + if ( $nb >0){ echo ""; if ($nb_used > 0) { @@ -148,13 +151,14 @@ class Acc_Plan_MTable extends Manage_Table_SQL echo ''; } + /** - * Check that the entered data are valid before recording them into + * Check that the entered data are valid before recording them into * tmp_pcmn, the errors are stored into this->a_error and if someting wrong * is found it returns false, if the data can be saved it returns true - * @return return false if an error is found, + * @return return false if an error is found, */ - function check() + function check() { $cn=Dossier::connect(); $count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val = $1 and id <> $2", @@ -180,12 +184,25 @@ class Acc_Plan_MTable extends Manage_Table_SQL if ($exist_parent == 0) { $this->set_error("parent_accounting", _("Compte parent n'existe pas")); } - if ( count($this->aerror) > 0 ) return false; + /** + * check that accounting is not already used + */ + $old_accounting = $cn->get_value("select pcm_val from tmp_pcmn where id = $1", + array($this->table->id)); + // it is not a new accounting and is different + if ($old_accounting != "" && $old_accounting != $this->table->pcm_val) { + // count it is used + if ($cn->get_value("select count(*) from jrnx where j_poste=$1", + [$old_accounting]) > 0) { + $this->set_error("pcm_val", _("Poste utilisé")); + } + } + if (count($this->aerror) > 0) return false; return true; } - + /** - * @brief display into a dialog box the datarow in order + * @brief display into a dialog box the datarow in order * to be appended or modified. Can be override if you need * a more complex form */ @@ -195,5 +212,31 @@ class Acc_Plan_MTable extends Manage_Table_SQL $dossier_id=Dossier::id(); echo HtmlInput::button_action(_("Toutes les fiches") , sprintf("display_all_card('%s','%s')",$dossier_id,$this->table->pcm_val)); } - + + /** + * if pcm_val already used then it cannot be modified + * + * @param $p_key always pcm_val + * @param $p_value current value of pcm_val + * @return nothing|void + */ + function input_custom($p_key, $p_value) + { + $readonly=true; + $cn=Dossier::connect(); + if ( + $p_value == "" || + ($p_value !="" && $cn->get_value("select count(*) from jrnx where j_poste=$1",[$p_value]) == 0 ) + ) + { + $readonly=false; + } + $text=new IText($p_key); + $text->setReadOnly($readonly); + $text->value=$p_value; + $min_size=(strlen($p_value)<30)?30:strlen($p_value)+5; + $text->size=$min_size; + echo $text->input(); + } + } diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index 3ee346156..635c25f64 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -530,10 +530,18 @@ class Fiche $w->name = "av_text" . $attr->ad_id; if ($attr->ad_id == 21 || $attr->ad_id==22||$attr->ad_id==20||$attr->ad_id==31) { - $bulle=Icon_Action::infobulle(21); + $bulle=Icon_Action::infobulle( 21); } - if ($attr->ad_id == ATTR_DEF_NAME || $attr->ad_id== ATTR_DEF_QUICKCODE) + + // Warning length quickcode + if ($attr->ad_id== ATTR_DEF_QUICKCODE ) { + $bulle=Icon_Action::warnbulle(76); + } + if ($attr->ad_id == ATTR_DEF_NAME || $attr->ad_id== ATTR_DEF_QUICKCODE) + { $class=" input_text highlight info"; + + } else $class="input_text"; $r.="" . td(_($w->label)." $bulle", ' class="'.$class.'" ') . td($w->input()." $msg")." "; @@ -721,6 +729,10 @@ class Fiche else $class="input_text"; + // Warning length quickcode + if ($r->ad_id== ATTR_DEF_QUICKCODE ) { + $bulle=Icon_Action::warnbulle(76); + } $ret.="".td(_($r->ad_text).$bulle,'class="'.$class.'"').td($w->input()." ".$msg)." "; } diff --git a/include/class/html_input_noalyss.class.php b/include/class/html_input_noalyss.class.php new file mode 100644 index 000000000..9fc1e2642 --- /dev/null +++ b/include/class/html_input_noalyss.class.php @@ -0,0 +1,61 @@ +value=1; + $num->size=2; + $s_js=sprintf(' onClick="ledger_add_multiple(\'%s\')"',$id); + + $r=HtmlInput::hidden($id."_ledger",$p_ledger); + $r.=$num->input(); + $r.=HtmlInput::button('add_item',_('ligne à ajouter'), + $s_js); + + return $r; + } +} \ No newline at end of file diff --git a/include/class/pre_op_ach.class.php b/include/class/pre_op_ach.class.php index 00fbad9b0..fb9640e77 100644 --- a/include/class/pre_op_ach.class.php +++ b/include/class/pre_op_ach.class.php @@ -40,18 +40,19 @@ class Pre_op_ach extends Pre_operation_detail function get_post() { parent::get_post(); + $http=new HttpInput(); $this->operation->od_direct='f'; - $this->e_client=$_POST['e_client']; + $this->e_client=$http->post('e_client'); for ($i=0;$i<$this->operation->nb_item;$i++) { $march="e_march".$i; - $this->$march=$_POST['e_march'.$i]; - $this->{"e_march".$i."_price"}=(isset ($_POST['e_march'.$i."_price"]))?$_POST['e_march'.$i."_price"]:0; - $this->{"e_march".$i."_price"}=(trim($_POST['e_march'.$i."_price"])=="")?0:$_POST['e_march'.$i."_price"]; - $this->{"e_march".$i."_tva_id"}=(isset ($_POST['e_march'.$i."_tva_id"]))?$_POST['e_march'.$i."_tva_id"]:0; - $this->{"e_march".$i."_tva_amount"}=(isset($_POST['e_march'.$i."_tva_amount"]))?$_POST['e_march'.$i."_tva_amount"]:0; - $this->{"e_march".$i."_label"}=(isset($_POST['e_march'.$i."_label"]))?$_POST['e_march'.$i."_label"]:null; - $this->{"e_quant".$i}=$_POST['e_quant'.$i]; + $this->$march=$http->post('e_march'.$i); + $this->{"e_march".$i."_price"}=$http->post('e_march'.$i."_price","string",0); + $this->{"e_march".$i."_price"}=$http->post('e_march'.$i."_price","string",0); + $this->{"e_march".$i."_tva_id"}=$http->post('e_march'.$i."_tva_id","string",0); + $this->{"e_march".$i."_tva_amount"}=$http->post('e_march'.$i."_tva_amount","string",0); + $this->{"e_march".$i."_label"}=$http->post('e_march'.$i."_label","string",NULL); + $this->{"e_quant".$i}=$http->post('e_quant'.$i); } } @@ -403,7 +404,7 @@ class Pre_op_ach extends Pre_operation_detail // Set correctly the REQUEST param for jrn_type $r.= HtmlInput::hidden('jrn_type','ACH'); - $r.= HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_add_row()"'); + $r.= Html_Input_Noalyss::ledger_add_item("O"); return $r; } diff --git a/include/class/pre_op_advanced.class.php b/include/class/pre_op_advanced.class.php index ec78536a7..2c110fe45 100644 --- a/include/class/pre_op_advanced.class.php +++ b/include/class/pre_op_advanced.class.php @@ -284,6 +284,7 @@ class Pre_Op_Advanced extends Pre_operation_detail // If readonly == 1 then show CA } $ret.=''; + $ret.=Html_Input_Noalyss::ledger_add_item("M"); return $ret; } } diff --git a/include/class/pre_op_ven.class.php b/include/class/pre_op_ven.class.php index 0a2c79dae..c76252c1b 100644 --- a/include/class/pre_op_ven.class.php +++ b/include/class/pre_op_ven.class.php @@ -406,8 +406,8 @@ class Pre_op_ven extends Pre_operation_detail // Set correctly the REQUEST param for jrn_type $r.=HtmlInput::hidden('jrn_type','VEN'); + $r.= Html_Input_Noalyss::ledger_add_item("O"); - $r.=HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_add_row()"'); return $r; } } diff --git a/include/class/pre_operation.class.php b/include/class/pre_operation.class.php index 885e7a1fd..8243b58bb 100644 --- a/include/class/pre_operation.class.php +++ b/include/class/pre_operation.class.php @@ -71,14 +71,14 @@ class Pre_operation /*!\brief fill the object with the $_POST variable */ function get_post() { - $this->nb_item=$_POST['nb_item']; - $this->p_jrn=$_REQUEST['p_jrn']; - $this->jrn_type=$_POST['jrn_type']; - - $this->name=$_POST['opd_name']; + $http=new HttpInput(); + $this->nb_item=$http->post('nb_item',"number"); + $this->p_jrn=$http->request('p_jrn',"number"); + $this->jrn_type=$http->post('jrn_type'); + $this->name=$http->post('opd_name'); - $this->name=(trim($this->name)=='')?$_POST['e_comm']:$this->name; - $this->description= $_POST['od_description']; + $this->name=(trim($this->name)=='')?$http->post('e_comm'):$this->name; + $this->description= $http->post('od_description'); if ( $this->name=="") { $n=$this->db->get_next_seq('op_def_op_seq'); @@ -106,7 +106,7 @@ class Pre_operation } if ( $this->count() > MAX_PREDEFINED_OPERATION ) { - echo ''.("Vous avez atteint le max. d'opération prédéfinie, désolé").''; + echo ''.("Vous avez atteint le max. d'opération prédéfinie, désolé").''; return false; } $sql='insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description)'. diff --git a/include/compta_fin.inc.php b/include/compta_fin.inc.php index 7b0f07fce..66d1eea01 100644 --- a/include/compta_fin.inc.php +++ b/include/compta_fin.inc.php @@ -149,7 +149,7 @@ try { echo $Ledger->input($array); - echo HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_fin_add_row()"'); + echo Html_Input_Noalyss::ledger_add_item("F"); echo HtmlInput::submit('save',_('Sauve')); echo HtmlInput::reset(_('Effacer')); diff --git a/include/export/export_balance_pdf.php b/include/export/export_balance_pdf.php index 2490bb13f..03bc3ee09 100644 --- a/include/export/export_balance_pdf.php +++ b/include/export/export_balance_pdf.php @@ -176,31 +176,32 @@ if (!empty($array)) { if (${'lvl' . $ind . '_old'} == '') ${'lvl' . $ind . '_old'} = substr($r['poste'], 0, $ind); if (${'lvl' . $ind . '_old'} != substr($r['poste'], 0, $ind)) { $pdf->SetFont('DejaVu', 'B', 7); - $pdf->LongLine(30, 6, ${'lvl' . $ind . '_old'}); + $strTotal=sprintf(_("Totaux %s "),${'lvl' . $ind . '_old'}); + $pdf->LongLine(30, 6, $strTotal,"TB"); $delta = bcsub(${'nlvl' . $ind}['solde_cred'], ${'nlvl' . $ind}['solde_deb']); $side = ($delta < 0) ? "D" : "C"; if ($previous == 1) { $delta_previous = bcsub(${'nlvl' . $ind}['solde_cred_previous'], ${'nlvl' . $ind}['solde_deb_previous']); $side_previous = ($delta_previous < 0) ? "D" : "C"; - $pdf->write_cell(60, 6, " ", 0, 0, 'R'); - $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_deb_previous']), 0, 0, 'R'); - $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_cred_previous']), 0, 0, 'R'); - $pdf->write_cell(22, 6, nbm(abs($delta_previous)) . " $side_previous", 0, 0, 'R'); + $pdf->write_cell(60, 6, sprintf(_("niveau %s"),$ind), "TB", 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_deb_previous']), "TB", 0, 'R'); + $pdf->write_cell(22, 6, nbm(${'nlvl' . $ind}['sum_cred_previous']), "TB", 0, 'R'); + $pdf->write_cell(22, 6, nbm(abs($delta_previous)) . " $side_previous", "TB", 0, 'R'); } else { - $pdf->write_cell(60, 6, " ", 0, 0, 'R'); + $pdf->write_cell(60, 6, sprintf(_("niveau %s"),$ind), "TB", 0, 'R'); } $solde_lv = bcsub(${'nlvl' . $ind}['sum_deb_ope'], ${'nlvl' . $ind}['sum_cred_ope']); $side_lv = ($solde_lv < 0) ? " C" : " D"; $side_lv = ($solde_lv == 0) ? " " : $side_lv; - $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . $side_lv, 0, 0, 'R'); - $pdf->write_cell(25, 6, nbm(bcsub(${'nlvl' . $ind}['sum_deb'], ${'nlvl' . $ind}['sum_deb_ope'])), 0, 0, 'R'); - $pdf->write_cell(25, 6, nbm(bcsub(${'nlvl' . $ind}['sum_cred'], ${'nlvl' . $ind}['sum_cred_ope'])), 0, 0, 'R'); + $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . $side_lv, "TB", 0, 'R'); + $pdf->write_cell(25, 6, nbm(bcsub(${'nlvl' . $ind}['sum_deb'], ${'nlvl' . $ind}['sum_deb_ope'])), "TB", 0, 'R'); + $pdf->write_cell(25, 6, nbm(bcsub(${'nlvl' . $ind}['sum_cred'], ${'nlvl' . $ind}['sum_cred_ope'])), "TB", 0, 'R'); $solde_lv = bcsub(${'nlvl' . $ind}['solde_deb'], ${'nlvl' . $ind}['solde_cred']); $side_lv = ($solde_lv > 0) ? "D" : "C"; $side_lv = ($solde_lv == 0) ? "" : $side_lv; - $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . " $side_lv", 0, 0, 'R'); + $pdf->write_cell(25, 6, nbm(abs($solde_lv)) . " $side_lv", "TB", 0, 'R'); $pdf->line_new(); $pdf->SetFont('DejaVuCond', '', 7); ${'lvl' . $ind . '_old'} = substr($r['poste'], 0, $ind); diff --git a/include/lib/html_tab.class.php b/include/lib/html_tab.class.php index ee3304a39..55b51c090 100644 --- a/include/lib/html_tab.class.php +++ b/include/lib/html_tab.class.php @@ -35,7 +35,7 @@ class Html_Tab private $content ; //!< static content of the tab private $mode ; //!< possible values are static if the content is static, ajax for calling an ajax, link for a html link, default static private $link; //!< the javascript or an html link, depending of the $mode - + private $comment; //!< comment to add when we use the row /** *@example html_tab.test.php */ @@ -44,7 +44,27 @@ class Html_Tab $this->id=$p_id; $this->title=$p_title; $this->mode='static'; + $this->comment=""; } + + /** + * @return string + */ + public function get_comment() + { + return $this->comment; + return $this; + } + + /** + * @param string $comment + */ + public function set_comment($comment) + { + $this->comment = $comment; + return $this; + } + public function get_id() { return $this->id; diff --git a/include/lib/message_javascript.php b/include/lib/message_javascript.php index c702b588e..6e54ab8d8 100644 --- a/include/lib/message_javascript.php +++ b/include/lib/message_javascript.php @@ -106,4 +106,5 @@ content[72]=""; content[74]=""; content[75]=""; +content[76]=""; \ No newline at end of file diff --git a/include/lib/noalyss_csv.class.php b/include/lib/noalyss_csv.class.php index 4eefce8d6..669403431 100644 --- a/include/lib/noalyss_csv.class.php +++ b/include/lib/noalyss_csv.class.php @@ -58,7 +58,7 @@ class Noalyss_Csv * Correct the name of the file , remove forbidden character and * add extension and date */ - private function correct_name() + protected function correct_name() { if (trim(strlen($this->filename))==0) { record_log('CSV->correct_name filename is empty'); @@ -157,7 +157,7 @@ class Noalyss_Csv /** * clean the row */ - private function clean() + protected function clean() { $this->element=array(); $this->size=0; @@ -166,7 +166,7 @@ class Noalyss_Csv * format the number for the CSV export * @param $p_number number */ - private function nb($p_number) + protected function nb($p_number) { $p_number=trim($p_number); if ($p_number=="") {return $p_number;} @@ -177,12 +177,118 @@ class Noalyss_Csv } return $r; } - private function encode($str) + protected function encode($str) { if ($this->encoding=="utf8") return $str; if ($this->encoding=="latin1") return utf8_decode ($str); throw new Exception(_("Encodage invalide")); } - + /** + * @return mixed + */ + public function get_filename() + { + return $this->filename; + return $this; + } + + /** + * @param mixed $filename + */ + public function set_filename($filename) + { + $this->filename = $filename; + return $this; + } + + /** + * @return array + */ + public function get_element() + { + return $this->element; + return $this; + } + + /** + * @param array $element + */ + public function set_element($element) + { + $this->element = $element; + return $this; + } + + /** + * @return mixed + */ + public function get_sep_field() + { + return $this->sep_field; + return $this; + } + + /** + * @param mixed $sep_field + */ + public function set_sep_field($sep_field) + { + $this->sep_field = $sep_field; + return $this; + } + + /** + * @return mixed + */ + public function get_sep_dec() + { + return $this->sep_dec; + return $this; + } + + /** + * @param mixed $sep_dec + */ + public function set_sep_dec($sep_dec) + { + $this->sep_dec = $sep_dec; + return $this; + } + + /** + * @return mixed + */ + public function get_encoding() + { + return $this->encoding; + return $this; + } + + /** + * @param mixed $encoding + */ + public function set_encoding($encoding) + { + $this->encoding = $encoding; + return $this; + } + + /** + * @return int + */ + public function get_size() + { + return $this->size; + return $this; + } + + /** + * @param int $size + */ + public function set_size($size) + { + $this->size = $size; + return $this; + } } diff --git a/include/lib/output_html_tab.class.php b/include/lib/output_html_tab.class.php index 943faa4e3..c8af50d90 100644 --- a/include/lib/output_html_tab.class.php +++ b/include/lib/output_html_tab.class.php @@ -37,24 +37,101 @@ class Output_Html_Tab { private $a_tabs; //!< array of html tabs - + private $class_tab; //!< for normal tab + private $class_tab_selected; //!< for class_tab_selected + private $mode; //!< mode default tabs /** *@example html_tab.test.php */ function __construct() { $this->a_tabs=[]; + $this->class_tab="tabs"; + $this->class_tab_selected="tabs_selected"; } /** - * Add Html_Tab + * get the mode , possible value are row or tabs + * @return mixed + */ + public function get_mode() + { + return $this->mode; + return $this; + } + + /** + * set the mode , possible values are row or tabs + * @param mixed $mode + */ + public function set_mode($mode) + { + if ($mode != "row" && $mode != "tab") { + throw new Exception(_("OUTPUTHTML070 Mode invalide")); + } + $this->mode = $mode; + if ($mode == "row") { + $this->set_class_tab_selected("tab_row_selected"); + $this->set_class_tab("tab_row"); + } + if ( $mode == "tab") { + $this->set_class_tab_selected("tabs_selected"); + $this->set_class_tab("tabs"); + + } + return $this; + } + + /** + * Add Html_Tab * @param Html_Tab $p_html_tab */ function add(Html_Tab $p_html_tab) { $this->a_tabs[]=clone $p_html_tab; + } - + + /** + * get the CSS class of tabs + * @return mixed + */ + public function get_class_tab() + { + return $this->class_tab; + return $this; + } + + /** + * set the CSS class of tabs, default is tabs + * @param mixed $class_tab + */ + public function set_class_tab($class_tab) + { + $this->class_tab = $class_tab; + return $this; + } + + /** + * get the CSS class of tabs_selected + * @return mixed + */ + public function get_class_tab_selected() + { + return $this->class_tab_selected; + return $this; + } + + /** + * set the CSS class of tabs, default is tabs_selected + * @param mixed $class_tab_selected + */ + public function set_class_tab_selected($class_tab_selected) + { + $this->class_tab_selected = $class_tab_selected; + return $this; + } + /** * Build the javascript to change the class name of the selected tab, hide other div and show the selected one * @param string $p_not_hidden id of the showed tab @@ -66,20 +143,44 @@ class Output_Html_Tab $nb=count($this->a_tabs); for ($i =0 ; $i < $nb;$i++) { - if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) { - $r .= sprintf("$('div%s').hide();",$this->a_tabs[$i]->get_id() ); - $r .= sprintf("$('tab%s').className='tabs';",$this->a_tabs[$i]->get_id() ); - } else { - $r .= sprintf("$('div%s').show();",$p_not_hidden ); - $r .= sprintf("$('tab%s').className='tabs_selected';",$p_not_hidden ); - + if ($this->get_mode()=="tab") { + + if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) { + $r .= sprintf("$('div%s').hide();",$this->a_tabs[$i]->get_id() ); + $r .= sprintf("$('tab%s').className='%s';",$this->a_tabs[$i]->get_id(),$this->class_tab ); + } else { + $r .= sprintf("$('div%s').show();",$p_not_hidden ); + $r .= sprintf("$('tab%s').className='%s';",$p_not_hidden ,$this->class_tab_selected); + + } + } elseif ($this->get_mode()=="row") { + if ( $this->a_tabs[$i]->get_id() != $p_not_hidden) { + $r .= sprintf("Effect.BlindUp('div%s',{duration : 0.7});",$this->a_tabs[$i]->get_id() ); + $r .= sprintf("$('tab%s').className='%s';",$this->a_tabs[$i]->get_id(),$this->class_tab ); + } else { + $r .= sprintf("Effect.SlideDown('div%s',{duration : 0.7});",$p_not_hidden ); + $r .= sprintf("$('tab%s').className='%s';",$p_not_hidden ,$this->class_tab_selected); + + } } } return $r; } + + /** + * When printing row , a comment is written if not empty + * @param $p_index + */ + protected function print_comment($p_index) { + printf (' %s ', + $this->get_class_tab(), + $this->a_tabs[$p_index]->get_comment() + ); + + } /** * print the html + javascript code of the tabs and the div - * + * */ function output() { @@ -88,18 +189,21 @@ class Output_Html_Tab { return; } - echo '