diff --git a/doc/manuel-fr.odt b/doc/manuel-fr.odt index 6c96da950..fb3d80abb 100644 Binary files a/doc/manuel-fr.odt and b/doc/manuel-fr.odt differ diff --git a/html/admin/sql/patch/upgrade70.sql b/html/admin/sql/patch/upgrade70.sql new file mode 100644 index 000000000..b064a264a --- /dev/null +++ b/html/admin/sql/patch/upgrade70.sql @@ -0,0 +1,4 @@ +begin; +insert into action (ac_id,ac_description,ac_module,ac_code) values (1135,'Ajoute ou modifie des catégories de documents','parametre','PARCATDOC'); +update version set val=71; +commit; diff --git a/html/ajax_misc.php b/html/ajax_misc.php index b28b4df5a..e52131033 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -53,13 +53,13 @@ $user=new User($cn); $user->check(true);$user->check_dossier($gDossier,true); $html=var_export($_REQUEST,true); switch($op) { + // display new calendar case 'cal': require_once('class_calendar.php'); /* others report */ $cal=new Calendar(); $cal->set_periode($per); - $html=""; $html=$cal->display(); $html=escape_xml($html); @@ -72,4 +72,46 @@ echo << EOF; break; + /* remove a cat of document */ + case 'rem_cat_doc': + require_once('class_document_type.php'); + // if user can not return error message + if( $user->check_action(PARCATDOC)==0 ) { + $html="nok"; + header('Content-type: text/xml; charset=UTF-8'); +echo << + +$html + +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 ) { + $html="nok"; + header('Content-type: text/xml; charset=UTF-8'); +echo << + +$html + +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 + +EOF; + return; + break; + } diff --git a/html/js/scripts.js b/html/js/scripts.js index b634d58d9..1d54b88a4 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -255,3 +255,25 @@ function loading() { return 'chargement'; echo ShowItem($array,'H','mtitle','mtitle',$def); @@ -192,7 +196,15 @@ if ( $p_action == 'divers') { require_once('fiche_def.inc.php'); return; } - + //---------------------------------------------------- + // Cat. Document + //---------------------------------------------------- + if ( $def== 6) { + $User->can_request(PARCATDOC,1); + require_once('cat_document.inc.php'); + return; + } + } //----------------------------------------------------- // Extension diff --git a/include/cat_document.inc.php b/include/cat_document.inc.php new file mode 100644 index 000000000..99559b686 --- /dev/null +++ b/include/cat_document.inc.php @@ -0,0 +1,41 @@ +insert($_POST['cat']); +} +$aList=Document_Type::get_list($cn); +$addCat=new IText('cat'); +$str_addCat=$addCat->input(); +$str_submit=HtmlInput::submit('add',_('Ajout')); +echo '
'; +require_once('template/list_category_document.php'); +echo '
'; +?> \ No newline at end of file diff --git a/include/class_document_type.php b/include/class_document_type.php index af1767cd4..effe782f0 100644 --- a/include/class_document_type.php +++ b/include/class_document_type.php @@ -42,11 +42,40 @@ class Document_type */ function get() { - $sql="select * from document_type where dt_id=".$this->dt_id; - $R=$this->db->exec_sql($sql); + $sql="select * from document_type where dt_id=$1"; + $R=$this->db->exec_sql($sql,array($this->dt_id)); $r=Database::fetch_array($R,0); $this->dt_id=$r['dt_id']; $this->dt_value=$r['dt_value']; } - + /** + *@brief get a list + *@parameter $p_cn database connection + *@return array of data from document_type + */ + static function get_list($p_cn) { + $sql="select * from document_type"; + $r=$p_cn->get_array($sql); + $array=array(); + for ($i=0;$ijavascript="cat_doc_remove('".$r[$i]['dt_id']."','".$_REQUEST['PHPSESSID']."','".Dossier::id()."');"; + $tmp['js_remove']=$bt->input(); + $tmp['dt_id']=$r[$i]['dt_id']; + $array[$i]=$tmp; + } + return $array; + } + function insert($p_value) { + $sql="insert into document_type(dt_value) values ($1)"; + 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)); + }catch (Exception $e){ + alert(j(_("Impossible d'ajouter [$p_value] ").$e->getMessage())); + } + } } diff --git a/include/class_fiche.php b/include/class_fiche.php index f56e85ba7..22b6c419e 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -577,21 +577,22 @@ Array echo_debug("insert ATTR_DEF_ACCOUNT"); $v=FormatString($value); try { + if (isNumber($v) == 1 || strpos($v,',') != 0) { - $sql=sprintf("select account_insert(%d,'%s')", - $this->id,$v); + $parameter=array($this->id,$v); + // $sql=sprintf("select account_insert(%d,'%s')",$this->id,$v); } else { - $sql=sprintf("select account_insert(%d,null)", - $this->id); + $parameter=array($this->id,null); + // $sql=sprintf("select account_insert(%d,null)", $this->id); } - $this->cn->exec_sql($sql); + $this->cn->exec_sql("select account_insert($1,$2)",$parameter); echo_debug(__FILE__,__LINE__,$sql); } catch (Exception $e) { throw new Exception ("Erreur : ce compte [$v] n'a pas de compte parent.". - "L'opération est annulée", + "L'opération est annulée", 1); } continue; @@ -749,14 +750,15 @@ Array $Ret=$this->cn->exec_sql($sql); /* update also the jrnx */ - $sql='update jrnx set j_poste=$1 where j_qcode in (select quick_code from vw_fiche_attr where f_id=$2)'; + /* The jrnx CANNOT BE UPDATED + $sql='update jrnx set j_poste=$1 where j_qcode in (select quick_code from vw_fiche_attr where f_id=$2)'; $this->cn->exec_sql( $sql, array($v,$this->id)); - + */ } catch (Exception $e) { throw new Exception(__LINE__."Erreur : ce compte [$v] n'a pas de compte parent.". - "L'opération est annulée"); + "L'opération est annulée"); } continue; diff --git a/include/class_html_input.php b/include/class_html_input.php index 405f2c4a2..af9e65acb 100755 --- a/include/class_html_input.php +++ b/include/class_html_input.php @@ -120,6 +120,8 @@ class HtmlInput { public function get_js_attr(){ require_once('function_javascript.php'); $attr=""; + if ( count($this->attribute) == 0) return ""; + /* Add properties at the widget */ for ($i=0;$i< count($this->attribute);$i++){ list($name,$value)=$this->attribute[$i]; diff --git a/include/constant.php b/include/constant.php index 21de7fc86..3459f8efa 100644 --- a/include/constant.php +++ b/include/constant.php @@ -26,7 +26,7 @@ require_once ('config.inc.php'); require_once('constant.security.php'); -define ("DBVERSION",70); +define ("DBVERSION",71); define ("MAX_COMPTE",4); define ('MAX_ARTICLE',9); diff --git a/include/constant.security.php b/include/constant.security.php index 5cff00899..847525636 100644 --- a/include/constant.security.php +++ b/include/constant.security.php @@ -25,6 +25,7 @@ define ("PARCA",1100); //Mode comptabilité analytique define ("PARPER",1110); //Ajout de période define ("PARFIC",1120); //Catégorie des fiches define ("PARDOC",1130); //Document +define ("PARCATDOC",1135); //Add Document category define ("PARJRN",1140); //Modification journaux define ("PARSEC",1245); /* Sécurité */ define ("PARTVA",1150); //TVA diff --git a/include/template/list_category_document.php b/include/template/list_category_document.php new file mode 100644 index 000000000..a188fd15c --- /dev/null +++ b/include/template/list_category_document.php @@ -0,0 +1,36 @@ +
+ + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ +
\ No newline at end of file