From 2b42ea4904a10e3045f654f734ecf03f9883bc83 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 2 Sep 2010 16:52:29 +0000 Subject: [PATCH] Works on canvas integration in third party module --- htdocs/core/class/canvas.class.php | 2 +- .../default/thirdparty.default.class.php | 10 +++++++-- .../thirdparty.individual.class.php | 10 +++++++-- htdocs/societe/soc.php | 21 ++++++++++++------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 3ea4d5642ce..23d85952c9e 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -68,7 +68,7 @@ class Canvas if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs)) { - $part1=$part3=$regs[2]; + $part1=$regs[2]; $part2=$regs[1]; } diff --git a/htdocs/societe/canvas/default/thirdparty.default.class.php b/htdocs/societe/canvas/default/thirdparty.default.class.php index 9c74d33a5b7..ccbaaa1dbcc 100644 --- a/htdocs/societe/canvas/default/thirdparty.default.class.php +++ b/htdocs/societe/canvas/default/thirdparty.default.class.php @@ -50,11 +50,17 @@ class ThirdPartyDefault extends Societe $this->fieldListName = "thirdparty_default"; } - function getTitle() + function getTitle($action) { global $langs; - return $langs->trans("ThirdParty"); + $out=''; + + if ($action == 'view') $out.= $langs->trans("ThirdParty"); + if ($action == 'edit') $out.= $langs->trans("EditCompany"); + if ($action == 'create') $out.= $langs->trans("NewCompany"); + + return $out; } /** diff --git a/htdocs/societe/canvas/individual/thirdparty.individual.class.php b/htdocs/societe/canvas/individual/thirdparty.individual.class.php index efc1add7c62..cff4d6fee2e 100644 --- a/htdocs/societe/canvas/individual/thirdparty.individual.class.php +++ b/htdocs/societe/canvas/individual/thirdparty.individual.class.php @@ -51,11 +51,17 @@ class ThirdPartyIndividual extends Societe $this->fieldListName = "thirdparty_individual"; } - function getTitle() + function getTitle($action) { global $langs; + + $out=''; - return $langs->trans("Individual"); + if ($action == 'view') $out.= $langs->trans("Individual"); + if ($action == 'edit') $out.= $langs->trans("EditIndividual"); + if ($action == 'create') $out.= $langs->trans("NewIndividual"); + + return $out; } /** diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index a04c11d4b74..d36b563f671 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -55,13 +55,13 @@ if (empty($_GET["canvas"])) { $_GET["canvas"] = 'default'; if ($_REQUEST["private"]==1) $_GET["canvas"] = 'individual'; + + // Get object canvas + $socstatic = new Societe($db); + if (!empty($socid)) $socstatic->getCanvas($socid); } -// Initialization Company Object -$socstatic = new Societe($db); - // Initialization Company Canvas -if (!empty($socid)) $socstatic->getCanvas($socid); $canvas = (!empty($socstatic->canvas)?$socstatic->canvas:$_GET["canvas"]); $soc = new Canvas($db); $soc->load_canvas('thirdparty@societe',$canvas); @@ -375,7 +375,8 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') */ if ($user->rights->societe->creer) { - print_fiche_titre($langs->trans("NewCompany")); + $title = $soc->object->getTitle('create'); + print_fiche_titre($title); $soc->object->assign_post(); @@ -394,7 +395,9 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') /* * Company Fact Mode edition */ - print_fiche_titre($langs->trans("EditCompany")); + + $title = $soc->object->getTitle('edit'); + print_fiche_titre($title); if ($socid) { @@ -403,7 +406,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') $soc = new Canvas($db); $soc->load_canvas('thirdparty@societe',$canvas); $soc->object->id = $socid; - $soc->fetch($socid, $_GET["action"]); + $soc->fetch($socid, 'edit'); } else { @@ -434,11 +437,13 @@ else } $head = societe_prepare_head($soc); + $title = $soc->object->getTitle('view'); - dol_fiche_head($head, 'company', $langs->trans("ThirdParty"),0,'company'); + dol_fiche_head($head, 'company', $title, 0, 'company'); // Assign values $soc->assign_values('view'); + // Display canvas $soc->display_canvas();