forked from Wavyzz/dolibarr
Make canvas for products working again.
This commit is contained in:
@@ -114,12 +114,13 @@ class Canvas
|
|||||||
* Shared method for canvas to assign values for templates
|
* Shared method for canvas to assign values for templates
|
||||||
*
|
*
|
||||||
* @param string &$action Action string
|
* @param string &$action Action string
|
||||||
* @param int $id Object id
|
* @param int $id Object id (if ref not provided)
|
||||||
|
* @param string $ref Object ref (if id not provided)
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function assign_values(&$action='view', $id=0)
|
function assign_values(&$action='view', $id=0, $ref='')
|
||||||
{
|
{
|
||||||
if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id);
|
if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,14 +43,16 @@ class ActionsCardProduct extends Product
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Handler acces base de donnees
|
* @param DoliDB $DB Database handler
|
||||||
* @param string $targetmodule Name of directory of module where canvas is stored
|
* @param string $dirmodule Name of directory of module
|
||||||
|
* @param string $targetmodule Name of directory where canvas is stored
|
||||||
* @param string $canvas Name of canvas
|
* @param string $canvas Name of canvas
|
||||||
* @param string $card Name of tab (sub-canvas)
|
* @param string $card Name of tab (sub-canvas)
|
||||||
*/
|
*/
|
||||||
function ActionsCardProduct($DB,$targetmodule,$canvas,$card)
|
function __construct($DB, $dirmodule, $targetmodule, $canvas, $card)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
|
$this->dirmodule = $dirmodule;
|
||||||
$this->targetmodule = $targetmodule;
|
$this->targetmodule = $targetmodule;
|
||||||
$this->canvas = $canvas;
|
$this->canvas = $canvas;
|
||||||
$this->card = $card;
|
$this->card = $card;
|
||||||
@@ -74,17 +76,44 @@ class ActionsCardProduct extends Product
|
|||||||
return $langs->trans("Products");
|
return $langs->trans("Products");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get object from id or ref and save it into this->object
|
||||||
|
*
|
||||||
|
* @param int $id Object id
|
||||||
|
* @param string $ref Ojbect ref
|
||||||
|
* @return Object Object loaded
|
||||||
|
*/
|
||||||
|
function getObject($id,$ref='')
|
||||||
|
{
|
||||||
|
$object = new Product($this->db);
|
||||||
|
if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref);
|
||||||
|
$this->object = $object;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||||
*
|
*
|
||||||
* @param string $action Type of action
|
* @param string &$action Type of action
|
||||||
|
* @param string $id Id of object
|
||||||
|
* @param string $ref Ref of object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function assign_values($action)
|
function assign_values(&$action, $id=0, $ref='')
|
||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf, $langs, $user, $mysoc, $canvas;
|
||||||
global $html, $formproduct;
|
global $html, $formproduct;
|
||||||
|
|
||||||
|
$ret = $this->getObject($id,$ref);
|
||||||
|
|
||||||
|
//parent::assign_values($action);
|
||||||
|
|
||||||
|
foreach($this->object as $key => $value)
|
||||||
|
{
|
||||||
|
$this->tpl[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tpl['error'] = get_htmloutput_errors($this->object->error,$this->object->errors);
|
||||||
|
|
||||||
// canvas
|
// canvas
|
||||||
$this->tpl['canvas'] = $this->canvas;
|
$this->tpl['canvas'] = $this->canvas;
|
||||||
|
|
||||||
@@ -133,8 +162,14 @@ class ActionsCardProduct extends Product
|
|||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
// Ref
|
$head = product_prepare_head($this->object,$user);
|
||||||
$this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
|
|
||||||
|
$this->tpl['showrefnav'] = $html->showrefnav($this->object,'ref','',1,'ref');
|
||||||
|
|
||||||
|
$titre=$langs->trans("CardProduct".$this->object->type);
|
||||||
|
$picto=($this->object->type==1?'service':'product');
|
||||||
|
$this->tpl['showhead']=dol_get_fiche_head($head, 'card', $titre, 0, $picto);
|
||||||
|
$this->tpl['showend']=dol_get_fiche_end();
|
||||||
|
|
||||||
// Accountancy buy code
|
// Accountancy buy code
|
||||||
$this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
|
$this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
|
||||||
@@ -196,11 +231,6 @@ class ActionsCardProduct extends Product
|
|||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
$head=product_prepare_head($this->object, $user);
|
|
||||||
$titre=$langs->trans("CardProduct".$this->object->type);
|
|
||||||
$picto=($this->object->type==1?'service':'product');
|
|
||||||
$this->tpl['fiche_head']=dol_get_fiche_head($head, 'card', $titre, 0, $picto);
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
$this->tpl['status'] = $this->object->getLibStatut(2,0);
|
$this->tpl['status'] = $this->object->getLibStatut(2,0);
|
||||||
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);
|
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
<?php echo $this->control->tpl['fiche_head']; ?>
|
<?php echo $this->control->tpl['showhead']; ?>
|
||||||
|
|
||||||
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
|
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
|
||||||
<td colspan="2"><?php echo $this->control->tpl['ref']; ?></td>
|
<td colspan="2"><?php echo $this->control->tpl['showrefnav']; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@@ -88,6 +88,6 @@
|
|||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php echo $this->control->tpl['fiche_end']; ?>
|
<?php echo $this->control->tpl['showend']; ?>
|
||||||
|
|
||||||
<!-- END PHP TEMPLATE -->
|
<!-- END PHP TEMPLATE -->
|
||||||
@@ -74,17 +74,45 @@ class ActionsCardService extends Product
|
|||||||
return $langs->trans("Products");
|
return $langs->trans("Products");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get object from id or ref and save it into this->object
|
||||||
|
*
|
||||||
|
* @param int $id Object id
|
||||||
|
* @param string $ref Ojbect ref
|
||||||
|
* @return Object Object loaded
|
||||||
|
*/
|
||||||
|
function getObject($id,$ref='')
|
||||||
|
{
|
||||||
|
$object = new Product($this->db);
|
||||||
|
if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref);
|
||||||
|
$this->object = $object;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||||
*
|
*
|
||||||
* @param string $action Type of action
|
* @param string &$action Type of action
|
||||||
|
* @param string $id Id of object
|
||||||
|
* @param string $ref Ref of object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function assign_values($action)
|
function assign_values(&$action, $id=0, $ref='')
|
||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf, $langs, $user, $mysoc, $canvas;
|
||||||
global $html, $formproduct;
|
global $html, $formproduct;
|
||||||
|
|
||||||
|
$ret = $this->getObject($id,$ref);
|
||||||
|
|
||||||
|
//parent::assign_values($action);
|
||||||
|
|
||||||
|
foreach($this->object as $key => $value)
|
||||||
|
{
|
||||||
|
$this->tpl[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tpl['error'] = get_htmloutput_errors($this->object->error,$this->object->errors);
|
||||||
|
|
||||||
// canvas
|
// canvas
|
||||||
$this->tpl['canvas'] = $this->canvas;
|
$this->tpl['canvas'] = $this->canvas;
|
||||||
|
|
||||||
@@ -133,8 +161,14 @@ class ActionsCardService extends Product
|
|||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
// Ref
|
$head = product_prepare_head($this->object,$user);
|
||||||
$this->tpl['ref'] = $html->showrefnav($this,'ref','',1,'ref');
|
|
||||||
|
$this->tpl['showrefnav'] = $html->showrefnav($this->object,'ref','',1,'ref');
|
||||||
|
|
||||||
|
$titre=$langs->trans("CardProduct".$this->object->type);
|
||||||
|
$picto=($this->object->type==1?'service':'product');
|
||||||
|
$this->tpl['showhead']=dol_get_fiche_head($head, 'card', $titre, 0, $picto);
|
||||||
|
$this->tpl['showend']=dol_get_fiche_end();
|
||||||
|
|
||||||
// Accountancy buy code
|
// Accountancy buy code
|
||||||
$this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
|
$this->tpl['accountancyBuyCodeKey'] = $html->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,'id',$this->id,$user->rights->produit->creer);
|
||||||
@@ -192,11 +226,6 @@ class ActionsCardService extends Product
|
|||||||
|
|
||||||
if ($action == 'view')
|
if ($action == 'view')
|
||||||
{
|
{
|
||||||
$head=product_prepare_head($this->object, $user);
|
|
||||||
$titre=$langs->trans("CardProduct".$this->object->type);
|
|
||||||
$picto=($this->object->type==1?'service':'product');
|
|
||||||
$this->tpl['fiche_head']=dol_get_fiche_head($head, 'card', $titre, 0, $picto);
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
$this->tpl['status'] = $this->object->getLibStatut(2,0);
|
$this->tpl['status'] = $this->object->getLibStatut(2,0);
|
||||||
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);
|
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- BEGIN PHP TEMPLATE -->
|
<!-- BEGIN PHP TEMPLATE -->
|
||||||
<?php echo $this->control->tpl['fiche_head']; ?>
|
<?php echo $this->control->tpl['showhead']; ?>
|
||||||
|
|
||||||
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
|
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
|
||||||
<td colspan="2"><?php echo $this->control->tpl['ref']; ?></td>
|
<td colspan="2"><?php echo $this->control->tpl['showrefnav']; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@@ -73,5 +73,5 @@
|
|||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php echo $this->control->tpl['fiche_end']; ?>
|
<?php echo $this->control->tpl['showend']; ?>
|
||||||
<!-- END PHP TEMPLATE -->
|
<!-- END PHP TEMPLATE -->
|
||||||
@@ -47,7 +47,7 @@ $mesg = ''; $error=0; $errors=array();
|
|||||||
|
|
||||||
$id=GETPOST('id');
|
$id=GETPOST('id');
|
||||||
$ref=GETPOST('ref');
|
$ref=GETPOST('ref');
|
||||||
$action=GETPOST('action');
|
$action=(GETPOST('action') ? GETPOST('action') : 'view');
|
||||||
$confirm=GETPOST('confirm');
|
$confirm=GETPOST('confirm');
|
||||||
$socid=GETPOST("socid");
|
$socid=GETPOST("socid");
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
@@ -66,8 +66,8 @@ if (! empty($canvas))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (isset($id) || isset($ref)) $value = isset($id)?$id:(isset($ref)?$ref:'');
|
$value = $ref?$ref:$id;
|
||||||
$type = isset($ref)?'ref':'rowid';
|
$type = $ref?'ref':'rowid';
|
||||||
$result=restrictedArea($user,'produit|service',$value,'product','','',$type, $objcanvas);
|
$result=restrictedArea($user,'produit|service',$value,'product','','',$type, $objcanvas);
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
@@ -81,7 +81,7 @@ $hookmanager->callHooks(array('product'));
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$parameters=array('socid'=>$socid);
|
$parameters=array('id'=>$id, 'ref'=>$ref, 'objcanvas'=>$objcanvas);
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ if (empty($reshook))
|
|||||||
if ($action == 'setproductaccountancycodebuy')
|
if ($action == 'setproductaccountancycodebuy')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($id);
|
$result=$product->fetch($id,$ref);
|
||||||
$product->accountancy_code_buy=$_POST["productaccountancycodebuy"];
|
$product->accountancy_code_buy=$_POST["productaccountancycodebuy"];
|
||||||
$result=$product->update($product->id,$user,1,0,1);
|
$result=$product->update($product->id,$user,1,0,1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@@ -105,7 +105,7 @@ if (empty($reshook))
|
|||||||
if ($action == 'setproductaccountancycodesell')
|
if ($action == 'setproductaccountancycodesell')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$result=$product->fetch($id);
|
$result=$product->fetch($id,$ref);
|
||||||
$product->accountancy_code_sell=$_POST["productaccountancycodesell"];
|
$product->accountancy_code_sell=$_POST["productaccountancycodesell"];
|
||||||
$result=$product->update($product->id,$user,1,0,1);
|
$result=$product->update($product->id,$user,1,0,1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@@ -118,9 +118,9 @@ if (empty($reshook))
|
|||||||
if ($action == 'fastappro')
|
if ($action == 'fastappro')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$product->fetch($id);
|
$result=$product->fetch($id,$ref);
|
||||||
$result=$product->fastappro($user);
|
$result=$product->fastappro($user);
|
||||||
Header("Location: fiche.php?id=".$id);
|
Header("Location: fiche.php?id=".$product->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ if (empty($reshook))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$product=new Product($db);
|
$product=new Product($db);
|
||||||
if ($product->fetch($id))
|
if ($product->fetch($id,$ref))
|
||||||
{
|
{
|
||||||
$product->ref = $ref;
|
$product->ref = $ref;
|
||||||
$product->libelle = $_POST["libelle"];
|
$product->libelle = $_POST["libelle"];
|
||||||
@@ -288,7 +288,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
$originalId = $id;
|
$originalId = $id;
|
||||||
if ($product->fetch($id) > 0)
|
if ($product->fetch($id,$ref) > 0)
|
||||||
{
|
{
|
||||||
$product->ref = GETPOST('clone_ref');
|
$product->ref = GETPOST('clone_ref');
|
||||||
$product->status = 0;
|
$product->status = 0;
|
||||||
@@ -343,7 +343,7 @@ if (empty($reshook))
|
|||||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||||
{
|
{
|
||||||
$object = new Product($db);
|
$object = new Product($db);
|
||||||
$object->fetch($id);
|
$object->fetch($id,$ref);
|
||||||
|
|
||||||
if ( ($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer) )
|
if ( ($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer) )
|
||||||
{
|
{
|
||||||
@@ -384,7 +384,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$result=$prod->fetch($id);
|
$result=$prod->fetch($id,$ref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$prod->error);
|
dol_print_error($db,$prod->error);
|
||||||
@@ -464,7 +464,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$result=$prod->fetch($id);
|
$result=$prod->fetch($id,$ref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$prod->error);
|
dol_print_error($db,$prod->error);
|
||||||
@@ -546,7 +546,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$result = $prod->fetch($id);
|
$result = $prod->fetch($id,$ref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$prod->error);
|
dol_print_error($db,$prod->error);
|
||||||
@@ -635,42 +635,18 @@ llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl);
|
|||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$formproduct = new FormProduct($db);
|
$formproduct = new FormProduct($db);
|
||||||
|
|
||||||
|
|
||||||
// TODO Mutualize this part of code (same than societe/soc.php and contact/fiche.php)
|
|
||||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||||
{
|
{
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// When used with CANVAS
|
// When used with CANVAS
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
if ($action == 'create')
|
if (! $objcanvas->hasActions() && ($id || $ref))
|
||||||
{
|
|
||||||
$objcanvas->assign_values($action); // Set value for templates
|
|
||||||
$objcanvas->display_canvas($action,0); // Show template
|
|
||||||
}
|
|
||||||
elseif ($action == 'edit')
|
|
||||||
{
|
|
||||||
$objcanvas->control->object=$objcanvas->getObject($socid); // TODO: Getting and storing object should be done into assign_values (for template with no code) or into tpl
|
|
||||||
if (empty($objcanvas->control->object))
|
|
||||||
{
|
{
|
||||||
$object = new Product($db);
|
$object = new Product($db);
|
||||||
$object->fetch($id);
|
$object->fetch($id, $ref); // For use with "pure canvas" (canvas that contains templates only)
|
||||||
$objcanvas->control->object=$object;
|
|
||||||
}
|
|
||||||
$objcanvas->assign_values($action); // Set value for templates
|
|
||||||
$objcanvas->display_canvas($action); // Show template
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$objcanvas->control->object=$objcanvas->getObject($socid); // TODO: Getting and storing object should be done into assign_values (for template with no code) or into tpl
|
|
||||||
if (empty($objcanvas->control->object))
|
|
||||||
{
|
|
||||||
$object = new Product($db);
|
|
||||||
$object->fetch($id);
|
|
||||||
$objcanvas->control->object=$object;
|
|
||||||
}
|
|
||||||
$objcanvas->assign_values('view');
|
|
||||||
$objcanvas->display_canvas('view'); // Show template
|
|
||||||
}
|
}
|
||||||
|
$objcanvas->assign_values($action, $id, $ref); // Set value for templates
|
||||||
|
$objcanvas->display_canvas(); // Show template
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,23 +86,24 @@ abstract class ActionsCardCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object
|
* Get object from id or ref and save it into this->object
|
||||||
*
|
*
|
||||||
* @param int Object id
|
* @param int Object id
|
||||||
|
* @param ref Object ref
|
||||||
* @return object Object loaded
|
* @return object Object loaded
|
||||||
*/
|
*/
|
||||||
function getObject($id)
|
function getObject($id,$ref='')
|
||||||
{
|
{
|
||||||
$ret = $this->getInstanceDao();
|
$ret = $this->getInstanceDao();
|
||||||
|
|
||||||
if (is_object($this->object) && method_exists($this->object,'fetch'))
|
if (is_object($this->object) && method_exists($this->object,'fetch'))
|
||||||
{
|
{
|
||||||
if (! empty($id)) $this->object->fetch($id);
|
if (! empty($id) || ! empty($ref)) $this->object->fetch($id,$ref);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$object = new Societe($this->db);
|
$object = new Societe($this->db);
|
||||||
if (! empty($id)) $object->fetch($id);
|
if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref);
|
||||||
$this->object = $object;
|
$this->object = $object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,12 +380,14 @@ abstract class ActionsCardCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set content of ->tpl array, to use into template
|
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||||
*
|
*
|
||||||
* @param string $action Type of action
|
* @param string &$action Type of action
|
||||||
* @return string HTML output
|
* @param string $id Id of object
|
||||||
|
* @param string $ref Ref of object
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function assign_values(&$action)
|
function assign_values(&$action, $id=0, $ref='')
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user, $mysoc, $canvas;
|
global $conf, $langs, $user, $mysoc, $canvas;
|
||||||
global $form, $formadmin, $formcompany;
|
global $form, $formadmin, $formcompany;
|
||||||
|
|||||||
@@ -90,15 +90,17 @@ class ActionsCardCompany extends ActionsCardCommon
|
|||||||
/**
|
/**
|
||||||
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||||
*
|
*
|
||||||
* @param string $action Type of action
|
* @param string &$action Type of action
|
||||||
|
* @param string $id Id of object
|
||||||
|
* @param string $ref Ref of object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function assign_values(&$action, $id)
|
function assign_values(&$action, $id=0, $ref='')
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user, $mysoc;
|
global $conf, $langs, $user, $mysoc;
|
||||||
global $form, $formadmin, $formcompany;
|
global $form, $formadmin, $formcompany;
|
||||||
|
|
||||||
$ret = $this->getObject($id);
|
$ret = $this->getObject($id,$ref);
|
||||||
|
|
||||||
parent::assign_values($action);
|
parent::assign_values($action);
|
||||||
|
|
||||||
|
|||||||
@@ -90,15 +90,17 @@ class ActionsCardIndividual extends ActionsCardCommon
|
|||||||
/**
|
/**
|
||||||
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||||
*
|
*
|
||||||
* @param string $action Type of action
|
* @param string &$action Type of action
|
||||||
|
* @param string $id Id of object
|
||||||
|
* @param string $ref Ref of object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function assign_values(&$action, $id)
|
function assign_values(&$action, $id=0, $ref='')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
global $form, $formcompany;
|
global $form, $formcompany;
|
||||||
|
|
||||||
$ret = $this->getObject($id);
|
$ret = $this->getObject($id,$ref);
|
||||||
|
|
||||||
parent::assign_values($action);
|
parent::assign_values($action);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user