From 821f5e93e36e167a32b4e7b2344c51c6e80389ea Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 13 Jun 2012 19:16:44 +0000 Subject: [PATCH] =?UTF-8?q?0000572:=20Ajout=20de=20d=C3=A9p=C3=B4t=20pour?= =?UTF-8?q?=20les=20stocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/ajax_misc.php | 5 +- html/js/scripts.js | 30 ++++- include/ajax_mod_stock_repo.php | 80 ++++++++++++ include/class_html_input.php | 5 +- include/class_own.php | 1 + include/company.inc.php | 218 +++++++++++++++++--------------- include/stock_cfg.inc.php | 160 +++++++++++++++++++++++ sql/upgrade.sql | 29 +++++ 8 files changed, 419 insertions(+), 109 deletions(-) create mode 100644 include/ajax_mod_stock_repo.php create mode 100644 include/stock_cfg.inc.php diff --git a/html/ajax_misc.php b/html/ajax_misc.php index d5ed12b59..7d71fd109 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -57,7 +57,7 @@ if ($cont != 0) exit(); extract($_REQUEST); set_language(); -global $g_user; +global $g_user,$cn; $cn = new Database($gDossier); $g_user = new User($cn); $g_user->check(true); @@ -547,6 +547,9 @@ EOF; case 'modify_menu'; require_once 'ajax_mod_menu.php'; break; + case 'mod_stock_repo': + require_once 'ajax_mod_stock_repo.php'; + break; default: var_dump($_GET); } diff --git a/html/js/scripts.js b/html/js/scripts.js index db552be84..72c6c0a13 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -418,7 +418,7 @@ function cat_doc_change(p_dt_id,p_dossier) removeDiv('change_doc_div'); waiting_box(); var action = new Ajax.Request( - "ajax_misc.php" , + "ajax_misc.php" , { method:'get', parameters:queryString, onFailure:ajax_misc_failure, @@ -1512,4 +1512,30 @@ function set_action_related(p_obj) alert(e.message); return false; } - } \ No newline at end of file + } + /** + *@brief change a document_modele + */ +function stock_repo_change(p_dossier,r_id) +{ + var queryString="gDossier="+p_dossier+"&op=mod_stock_repo"+"&r_id="+r_id; + var nTop=calcy(posY); + var nLeft="200px"; + var str_style="top:"+nTop+"px;left:"+nLeft+";width:50em;height:auto"; + + removeDiv('change_stock_repo_div'); + waiting_box(); + var action = new Ajax.Request( + "ajax_misc.php" , + { + method:'get', parameters:queryString, + onFailure:ajax_misc_failure, + onSuccess:function(req){ + remove_waiting_box(); + add_div({id:'change_stock_repo_div',style:str_style,cssclass:'inner_box',drag:"1"}); + $('change_stock_repo_div').innerHTML=req.responseText; + + } + } + ); +} diff --git a/include/ajax_mod_stock_repo.php b/include/ajax_mod_stock_repo.php new file mode 100644 index 000000000..4bb467253 --- /dev/null +++ b/include/ajax_mod_stock_repo.php @@ -0,0 +1,80 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ Nom + + r_name); echo $name->input();?> +
+ Adresse + + r_adress); echo $name->input();?> +
+ Ville + + r_city); echo $name->input();?> +
+ Pays + + r_country); echo $name->input();?> +
+ Téléphone + + r_phone); echo $name->input();?> +
+ +
\ No newline at end of file diff --git a/include/class_html_input.php b/include/class_html_input.php index 99f0b15fe..77bc7e0e7 100755 --- a/include/class_html_input.php +++ b/include/class_html_input.php @@ -588,9 +588,10 @@ class HtmlInput } return $array[$ind]; } - static function title_box($name,$div) + static function title_box($name,$div,$mod="close") { - $r=HtmlInput::anchor_close($div); + if ($mod=='close') $r=HtmlInput::anchor_close($div); + if ($mod=='hide') $r=HtmlInput::anchor_hide(_('Fermer'),"$('$div').hide()"); $r.=h2info($name); return $r; } diff --git a/include/class_own.php b/include/class_own.php index 6edacaac6..8795ae483 100644 --- a/include/class_own.php +++ b/include/class_own.php @@ -105,6 +105,7 @@ class Own $this->save('MY_DATE_SUGGEST'); $this->save('MY_ALPHANUM'); $this->save('MY_UPDLAB'); + $this->save('MY_STOCK'); } diff --git a/include/company.inc.php b/include/company.inc.php index ec2d1e1f0..ce847911a 100644 --- a/include/company.inc.php +++ b/include/company.inc.php @@ -1,120 +1,130 @@ '; - require_once("class_own.php"); - if ( isset ($_POST['record_company'] )) - { - $m=new Own($cn); - extract($_POST); - $m->MY_NAME=$p_name; - $m->MY_TVA=$p_tva; - $m->MY_STREET=$p_street; - $m->MY_NUMBER=$p_no; - $m->MY_CP=$p_cp; - $m->MY_COMMUNE=$p_Commune; - $m->MY_TEL=$p_tel; - $m->MY_FAX=$p_fax; - $m->MY_PAYS=$p_pays; - $m->MY_CHECK_PERIODE=$p_check_periode; - $m->MY_DATE_SUGGEST=$p_date_suggest; - $m->MY_ANALYTIC=$p_compta; - $m->MY_STRICT=$p_strict; - $m->MY_TVA_USE=$p_tva_use; - $m->MY_PJ_SUGGEST=$p_pj; - $m->MY_ALPHANUM=$p_alphanum; - $m->MY_UPDLAB=$p_updlab; +echo '
'; +require_once("class_own.php"); +if (isset($_POST['record_company'])) +{ + $m = new Own($cn); + extract($_POST); + $m->MY_NAME = $p_name; + $m->MY_TVA = $p_tva; + $m->MY_STREET = $p_street; + $m->MY_NUMBER = $p_no; + $m->MY_CP = $p_cp; + $m->MY_COMMUNE = $p_Commune; + $m->MY_TEL = $p_tel; + $m->MY_FAX = $p_fax; + $m->MY_PAYS = $p_pays; + $m->MY_CHECK_PERIODE = $p_check_periode; + $m->MY_DATE_SUGGEST = $p_date_suggest; + $m->MY_ANALYTIC = $p_compta; + $m->MY_STRICT = $p_strict; + $m->MY_TVA_USE = $p_tva_use; + $m->MY_PJ_SUGGEST = $p_pj; + $m->MY_ALPHANUM = $p_alphanum; + $m->MY_UPDLAB = $p_updlab; + $m->MY_STOCK = $p_stock; - $m->Update(); - } + $m->Update(); +} - $my=new Own($cn); - ///// Compta analytic - $array=array ( - array("value"=>"ob",'label'=>_("obligatoire")), - array("value"=>"op",'label'=>_("optionnel")), - array("value"=>"nu",'label'=>_("non utilisé")) - ); - $strict_array=array( - array('value'=>'N','label'=>_('Non')), - array('value'=>'Y','label'=>_('Oui')) - ); +$my = new Own($cn); +///// Compta analytic +$array = array( + array("value" => "ob", 'label' => _("obligatoire")), + array("value" => "op", 'label' => _("optionnel")), + array("value" => "nu", 'label' => _("non utilisé")) +); +$strict_array = array( + array('value' => 'N', 'label' => _('Non')), + array('value' => 'Y', 'label' => _('Oui')) +); - $alpha_num_array[0]=array('value'=>'N','label'=>_('Non')); - $alpha_num_array[1]=array('value'=>'Y','label'=>_('Oui')); - - $updlab_array[0]=array('value'=>'N','label'=>_('Non')); - $updlab_array[1]=array('value'=>'Y','label'=>_('Oui')); +$alpha_num_array[0] = array('value' => 'N', 'label' => _('Non')); +$alpha_num_array[1] = array('value' => 'Y', 'label' => _('Oui')); - $compta=new ISelect(); - $compta->table=1; - $compta->selected=$my->MY_ANALYTIC; +$updlab_array[0] = array('value' => 'N', 'label' => _('Non')); +$updlab_array[1] = array('value' => 'Y', 'label' => _('Oui')); - $strict=new ISelect(); - $strict->table=1; - $strict->selected=$my->MY_STRICT; +$compta = new ISelect(); +$compta->table = 1; +$compta->selected = $my->MY_ANALYTIC; - $tva_use=new ISelect(); - $tva_use->table=1; - $tva_use->selected=$my->MY_TVA_USE; +$strict = new ISelect(); +$strict->table = 1; +$strict->selected = $my->MY_STRICT; - $pj_suggest=new ISelect(); - $pj_suggest->table=1; - $pj_suggest->selected=$my->MY_PJ_SUGGEST; +$tva_use = new ISelect(); +$tva_use->table = 1; +$tva_use->selected = $my->MY_TVA_USE; - $date_suggest=new ISelect(); - $date_suggest->table=1; - $date_suggest->selected=$my->MY_DATE_SUGGEST; +$pj_suggest = new ISelect(); +$pj_suggest->table = 1; +$pj_suggest->selected = $my->MY_PJ_SUGGEST; - $check_periode=new ISelect(); - $check_periode->table=1; - $check_periode->selected=$my->MY_CHECK_PERIODE; - $alpha_num=new ISelect(); - $alpha_num->table=1; - $alpha_num->value=$alpha_num_array; - $alpha_num->selected=$my->MY_ALPHANUM; +$date_suggest = new ISelect(); +$date_suggest->table = 1; +$date_suggest->selected = $my->MY_DATE_SUGGEST; - $updlab=new ISelect(); - $updlab->table=1; - $updlab->value=$updlab_array; - $updlab->selected=$my->MY_UPDLAB; +$check_periode = new ISelect(); +$check_periode->table = 1; +$check_periode->selected = $my->MY_CHECK_PERIODE; +$alpha_num = new ISelect(); +$alpha_num->table = 1; +$alpha_num->value = $alpha_num_array; +$alpha_num->selected = $my->MY_ALPHANUM; - // other parameters - $all=new IText(); - $all->table=1; - echo '
'; - echo dossier::hidden(); - echo ""; - echo "".td(_('Nom société'),'style="text-align:right"').$all->input("p_name",$my->MY_NAME).""; - $all->value=''; - echo "".td(_("Téléphone"),'style="text-align:right"').$all->input("p_tel",$my->MY_TEL).""; - $all->value=''; - echo "".td(_("Fax"),'style="text-align:right"').$all->input("p_fax",$my->MY_FAX).""; - $all->value=''; - echo "".td(_("Rue "),'style="text-align:right"').$all->input("p_street",$my->MY_STREET).""; - $all->value=''; - echo "".td(_("Numéro"),'style="text-align:right"').$all->input("p_no",$my->MY_NUMBER).""; - $all->value=''; - echo "".td(_("Code Postal"),'style="text-align:right"').$all->input("p_cp",$my->MY_CP).""; - $all->value=''; - echo "".td(_("Commune"),'style="text-align:right"').$all->input("p_Commune",$my->MY_COMMUNE).""; - $all->value=''; - echo "".td(_("Pays"),'style="text-align:right"').$all->input("p_pays",$my->MY_PAYS).""; - $all->value=''; - echo "".td(_("Numéro de Tva"),'style="text-align:right"').$all->input("p_tva",$my->MY_TVA).""; - echo "".td(_("Utilisation de la compta. analytique"),'style="text-align:right"').$compta->input("p_compta",$array).""; - - echo "".td(_("Utilisation du mode strict "),'style="text-align:right"').$strict->input("p_strict",$strict_array).""; - echo "".td(_("Assujetti à la tva"),'style="text-align:right"').$tva_use->input("p_tva_use",$strict_array).""; - echo "".td(_("Suggérer le numéro de pièce justificative"),'style="text-align:right"').$pj_suggest->input("p_pj",$strict_array).""; - echo "".td(_("Suggérer la date"),'style="text-align:right"').$date_suggest->input("p_date_suggest",$strict_array).""; - echo ''.td(_('Afficher la période comptable pour éviter les erreurs de date'),'style="text-align:right"').$check_periode->input('p_check_periode',$strict_array).''; - echo ''.td(_('Utilisez des postes comptables alphanumérique'),'style="text-align:right"').$alpha_num->input('p_alphanum').''; - echo ''.td(_('Changer le libellé des détails en VEN ou ACH'),'style="text-align:right"').$updlab->input('p_updlab').''; +$updlab = new ISelect(); +$updlab->table = 1; +$updlab->value = $updlab_array; +$updlab->selected = $my->MY_UPDLAB; - echo "
"; - echo HtmlInput::submit("record_company",_("Sauve")); - echo "
"; - echo '
'; - exit(); +$stock = new ISelect('p_stock'); +$stock->value = array( + array('value' => 'N', 'label' => _('Non')), + array('value' => 'Y', 'label' => _('Oui')) +); +$stock->selected = $my->MY_STOCK; +$stock->table = 1; +// other parameters +$all = new IText(); +$all->table = 1; +echo '
'; +echo dossier::hidden(); +echo ""; +echo "" . td(_('Nom société'), 'style="text-align:right"') . $all->input("p_name", $my->MY_NAME) . ""; +$all->value = ''; +echo "" . td(_("Téléphone"), 'style="text-align:right"') . $all->input("p_tel", $my->MY_TEL) . ""; +$all->value = ''; +echo "" . td(_("Fax"), 'style="text-align:right"') . $all->input("p_fax", $my->MY_FAX) . ""; +$all->value = ''; +echo "" . td(_("Rue "), 'style="text-align:right"') . $all->input("p_street", $my->MY_STREET) . ""; +$all->value = ''; +echo "" . td(_("Numéro"), 'style="text-align:right"') . $all->input("p_no", $my->MY_NUMBER) . ""; +$all->value = ''; +echo "" . td(_("Code Postal"), 'style="text-align:right"') . $all->input("p_cp", $my->MY_CP) . ""; +$all->value = ''; +echo "" . td(_("Commune"), 'style="text-align:right"') . $all->input("p_Commune", $my->MY_COMMUNE) . ""; +$all->value = ''; +echo "" . td(_("Pays"), 'style="text-align:right"') . $all->input("p_pays", $my->MY_PAYS) . ""; +$all->value = ''; +echo "" . td(_("Numéro de Tva"), 'style="text-align:right"') . $all->input("p_tva", $my->MY_TVA) . ""; +echo "" . td(_("Utilisation de la compta. analytique"), 'style="text-align:right"') . $compta->input("p_compta", $array) . ""; +echo "" . td(_("Utilisation des stocks"), 'style="text-align:right"') . $stock->input() . ""; + +echo "" . td(_("Utilisation du mode strict "), 'style="text-align:right"') . $strict->input("p_strict", $strict_array) . ""; +echo "" . td(_("Assujetti à la tva"), 'style="text-align:right"') . $tva_use->input("p_tva_use", $strict_array) . ""; +echo "" . td(_("Suggérer le numéro de pièce justificative"), 'style="text-align:right"') . $pj_suggest->input("p_pj", $strict_array) . ""; +echo "" . td(_("Suggérer la date"), 'style="text-align:right"') . $date_suggest->input("p_date_suggest", $strict_array) . ""; +echo '' . td(_('Afficher la période comptable pour éviter les erreurs de date'), 'style="text-align:right"') . $check_periode->input('p_check_periode', $strict_array) . ''; +echo '' . td(_('Utilisez des postes comptables alphanumérique'), 'style="text-align:right"') . $alpha_num->input('p_alphanum') . ''; +echo '' . td(_('Changer le libellé des détails en VEN ou ACH'), 'style="text-align:right"') . $updlab->input('p_updlab') . ''; + +echo "
"; +echo HtmlInput::submit("record_company", _("Sauve")); +echo "
"; +echo ''; +exit(); ?> diff --git a/include/stock_cfg.inc.php b/include/stock_cfg.inc.php new file mode 100644 index 000000000..3d2fdb1c8 --- /dev/null +++ b/include/stock_cfg.inc.php @@ -0,0 +1,160 @@ +MY_STOCK == 'N') +{ + echo '

'; + echo _("Vous n'utilisez pas de gestion de stock"); + echo '

'; + exit(); +} +if ( isset ($_POST['add_stock'])) +{ + $st=new Stock_Sql(); + $st->from_array($_POST); + $st->insert(); + +} +if ( isset ($_POST['mod_stock'])) +{ + $st=new Stock_Sql($_POST['r_id']); + $st->from_array($_POST); + $st->update(); + +} +$tb=new Sort_Table(); +$p_url=HtmlInput::get_to_string(array("ac","gDossier")); + +$tb->add(_("Nom"), $p_url, " order by r_name asc", "order by r_name desc", "ona", "ond"); +$tb->add(_("Adresse"), $p_url, " order by r_adress asc", "order by r_adress desc", "oaa", "oad"); +$tb->add(_("Ville"), $p_url, " order by r_city asc", "order by r_city desc", "ova", "ovd"); +$tb->add(_("Pays"), $p_url, " order by r_country asc", "order by r_country desc", "opa", "opd"); +$tb->add(_("Téléphone"), $p_url, " order by r_phone asc", "order by r_phone desc", "opa", "opd"); + +$sql="select * from stock_repository "; + +$ord=(isset($_GET['ord']))?$_GET['ord']:"ona"; + +$order=$tb->get_sql_order($ord); + +$array=$cn->get_array($sql." ".$order); + +?> +
+ + + + + + + + + + + + + + + + + + + + +
get_header(0)?>get_header(1)?>get_header(2)?>get_header(3)?>get_header(4)?>
+ + + + + + + + + + + +
+ + +
diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 147f9d9b9..f0dc25a99 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -212,3 +212,32 @@ COMMENT ON COLUMN user_sec_action_profile.ua_right IS 'Type of right : R for rea INSERT INTO profile (p_name, p_id, p_desc, with_calc, with_direct_form) VALUES ('Public', -1, 'faux groupe', NULL, NULL); insert into user_sec_action_profile(p_id,p_granted,ua_right) select 1,p_id,'W' from profile; insert into user_sec_action_profile(p_id,p_granted ,ua_right) select 2,p_id,'W' from profile; +insert into parameter values('MY_STOCK','N'); + +INSERT INTO menu_ref(me_code, me_menu, me_file, me_url, me_description, me_parameter, + me_javascript, me_type) + VALUES ('CFGSTOCK', 'Configuration des dépôts', 'stock_cfg.inc.php', null, 'Configuration dépôts', null,null,'ME'); + +INSERT INTO profile_menu(me_code, me_code_dep, p_id, p_order, p_type_display, pm_default) + VALUES ('CFGSTOCK', 'PARAM', 1, 40, 'E', 0); + +CREATE TABLE stock_repository +( + r_id bigserial NOT NULL, -- pk + r_name text, -- name of the stock + r_adress text, -- adress of the stock + r_country text, -- country of the stock + r_city text, -- City of the stock + r_phone text, -- City of the stock + CONSTRAINT stock_repository_pkey PRIMARY KEY (r_id ) +); + +COMMENT ON TABLE stock_repository IS 'stock repository'; +COMMENT ON COLUMN stock_repository.r_id IS 'pk'; +COMMENT ON COLUMN stock_repository.r_name IS 'name of the stock'; +COMMENT ON COLUMN stock_repository.r_adress IS 'adress of the stock'; +COMMENT ON COLUMN stock_repository.r_country IS 'country of the stock'; +COMMENT ON COLUMN stock_repository.r_city IS 'City of the stock'; +COMMENT ON COLUMN stock_repository.r_phone IS 'Phone number'; + +insert into stock_repository(r_name) values ('Dépôt par défaut'); \ No newline at end of file