From 2d552df6be1a237e7c0f885bc0df8eadae386254 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 2 Sep 2010 14:36:36 +0000 Subject: [PATCH] Works on canvas integration in third party module --- .../societe/canvas/default/tpl/create.tpl.php | 3 + .../societe/canvas/default/tpl/edit.tpl.php | 2 + .../canvas/individual/tpl/create.tpl.php | 5 +- .../canvas/individual/tpl/edit.tpl.php | 2 + htdocs/societe/class/societe.class.php | 85 +++++++++++++++++-- htdocs/societe/soc.php | 47 ---------- 6 files changed, 90 insertions(+), 54 deletions(-) diff --git a/htdocs/societe/canvas/default/tpl/create.tpl.php b/htdocs/societe/canvas/default/tpl/create.tpl.php index 6467e690e30..1c151d8f4ec 100644 --- a/htdocs/societe/canvas/default/tpl/create.tpl.php +++ b/htdocs/societe/canvas/default/tpl/create.tpl.php @@ -21,6 +21,9 @@ +object->tpl['ajax_select_thirdpartytype']; ?> +object->tpl['ajax_select_country']; ?> +
" method="POST" name="formsoc"> diff --git a/htdocs/societe/canvas/default/tpl/edit.tpl.php b/htdocs/societe/canvas/default/tpl/edit.tpl.php index 5f7aa2801c0..44545e807a5 100644 --- a/htdocs/societe/canvas/default/tpl/edit.tpl.php +++ b/htdocs/societe/canvas/default/tpl/edit.tpl.php @@ -21,6 +21,8 @@ +object->tpl['ajax_select_country']; ?> + " method="POST" name="formsoc"> diff --git a/htdocs/societe/canvas/individual/tpl/create.tpl.php b/htdocs/societe/canvas/individual/tpl/create.tpl.php index 74aca92e605..898c2d2f7b4 100644 --- a/htdocs/societe/canvas/individual/tpl/create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/create.tpl.php @@ -21,13 +21,16 @@ +object->tpl['ajax_select_thirdpartytype']; ?> +object->tpl['ajax_select_country']; ?> + " method="POST" name="formsoc"> -code_auto || $modCodeFournisseur->code_auto) { ?> +object->tpl['auto_customercode'] || $this->object->tpl['auto_suppliercode']) { ?> diff --git a/htdocs/societe/canvas/individual/tpl/edit.tpl.php b/htdocs/societe/canvas/individual/tpl/edit.tpl.php index 0fbbb654a10..fa363666cbf 100644 --- a/htdocs/societe/canvas/individual/tpl/edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/edit.tpl.php @@ -21,6 +21,8 @@ +object->tpl['ajax_select_country']; ?> + " method="POST" name="formsoc"> diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 6d7d557bad4..3a1476308bd 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2155,6 +2155,12 @@ class Societe extends CommonObject global $conf, $langs, $user, $mysoc; global $form, $formadmin, $formcompany; + if ($_GET["type"]=='f') { $this->fournisseur=1; } + if ($_GET["type"]=='c') { $this->client=1; } + if ($_GET["type"]=='p') { $this->client=2; } + if ($_GET["type"]=='cp') { $this->client=3; } + if ($_REQUEST["private"]==1) { $this->particulier=1; } + foreach($this as $key => $value) { $this->tpl[$key] = $value; @@ -2162,11 +2168,9 @@ class Societe extends CommonObject if ($action == 'create' || $action == 'edit') { - if ($_GET["type"]=='f') { $this->fournisseur=1; } - if ($_GET["type"]=='c') { $this->client=1; } - if ($_GET["type"]=='p') { $this->client=2; } - if ($_GET["type"]=='cp') { $this->client=3; } - if ($_REQUEST["private"]==1) { $this->particulier=1; } + // Chargement ajax + $this->tpl['ajax_select_thirdpartytype'] = $this->ajax_selectThirdPartyType(); + $this->tpl['ajax_select_country'] = $this->ajax_selectCountry($action); // Load object modCodeClient $module=$conf->global->SOCIETE_CODECLIENT_ADDON; @@ -2373,6 +2377,8 @@ class Societe extends CommonObject */ function assign_post() { + global $langs, $mysoc; + $this->id = $_POST["socid"]; $this->nom = $_POST["nom"]; $this->prefix_comm = $_POST["prefix_comm"]; @@ -2420,12 +2426,79 @@ class Societe extends CommonObject } else { - dol_print_error($db); + dol_print_error($this->db); } $this->pays_code = $obj->code; $this->pays = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } } + + /** + * + */ + function ajax_selectThirdPartyType() + { + global $conf, $langs; + + $out=''; + + if ($conf->use_javascript_ajax) + { + $out.= "\n".''."\n"; + + $out.= "
\n"; + $out.= $langs->trans("ThirdPartyType").':   '; + $out.= 'trans("Company/Fundation"); + $out.= '     '; + $out.= 'trans("Individual"); + $out.= ' ('.$langs->trans("ToCreateContactWithSameName").')'; + $out.= "
\n"; + $out.= "
\n"; + } + + return $out; + } + + /** + * + */ + function ajax_selectCountry($action) + { + global $conf; + + $out=''; + + if ($conf->use_javascript_ajax) + { + $out.= "\n".''."\n"; + } + + return $out; + } } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index ee78a420994..a04c11d4b74 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -382,41 +382,6 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') // Assign values $soc->assign_values('create'); - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - - print "
\n"; - print $langs->trans("ThirdPartyType").':   '; - print ' '.$langs->trans("Company/Fundation"); - print '     '; - print ' '.$langs->trans("Individual"); - print ' ('.$langs->trans("ToCreateContactWithSameName").')'; - print "
\n"; - print "
\n"; - } - dol_htmloutput_errors($soc->object->error,$soc->object->errors); // Display canvas @@ -446,18 +411,6 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') } dol_htmloutput_errors($soc->object->error,$soc->object->errors); - - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } // Assign values $soc->assign_values('edit');