Fix: Try to fix several bugs into canvas feature.
This commit is contained in:
parent
763e2a96a4
commit
8481af9ee4
@ -284,10 +284,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if (! $objcanvas->hasActions() && $id)
|
||||
if (empty($object->error) && $id)
|
||||
{
|
||||
$object = new Societe($db);
|
||||
$object->fetch($id); // For use with "pure canvas" (canvas that contains templates only)
|
||||
$object = new Contact($db);
|
||||
$object->fetch($id);
|
||||
}
|
||||
$objcanvas->assign_values($action, $id); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
|
||||
@ -1,450 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/product/canvas/product/actions_card_product.class.php
|
||||
* \ingroup produit
|
||||
* \brief Fichier de la classe des produits par defaut
|
||||
*/
|
||||
include_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
||||
|
||||
/**
|
||||
* \class ActionsCardProduct
|
||||
* \brief Class with controller methods for product canvas
|
||||
*/
|
||||
class ActionsCardProduct extends Product
|
||||
{
|
||||
var $targetmodule;
|
||||
var $canvas;
|
||||
var $card;
|
||||
|
||||
//! Template container
|
||||
var $tpl = array();
|
||||
|
||||
// List of fiels for action=list
|
||||
var $field_list =array();
|
||||
public $list_datas = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $DB Database handler
|
||||
* @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 $card Name of tab (sub-canvas)
|
||||
*/
|
||||
function __construct($DB, $dirmodule, $targetmodule, $canvas, $card)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->dirmodule = $dirmodule;
|
||||
$this->targetmodule = $targetmodule;
|
||||
$this->canvas = $canvas;
|
||||
$this->card = $card;
|
||||
|
||||
$this->name = "product";
|
||||
$this->definition = "Product canvas (défaut)";
|
||||
$this->fieldListName = "product_default";
|
||||
$this->next_prev_filter = "canvas='product'";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||
*
|
||||
* @param string &$action Type of action
|
||||
* @param string $id Id of object
|
||||
* @param string $ref Ref of object
|
||||
* @return void
|
||||
*/
|
||||
function assign_values(&$action, $id=0, $ref='')
|
||||
{
|
||||
global $conf, $langs, $user, $mysoc, $canvas;
|
||||
global $form, $formproduct;
|
||||
|
||||
$tmpobject = new Product($this->db);
|
||||
if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref);
|
||||
$this->object = $tmpobject;
|
||||
|
||||
//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
|
||||
$this->tpl['canvas'] = $this->canvas;
|
||||
|
||||
// id
|
||||
$this->tpl['id'] = $this->id;
|
||||
|
||||
// Ref
|
||||
$this->tpl['ref'] = $this->ref;
|
||||
|
||||
// Label
|
||||
$this->tpl['label'] = $this->libelle;
|
||||
|
||||
// Description
|
||||
$this->tpl['description'] = nl2br($this->description);
|
||||
|
||||
// Statut
|
||||
$this->tpl['status'] = $this->getLibStatut(2);
|
||||
|
||||
// Note
|
||||
$this->tpl['note'] = nl2br($this->note);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
// Price
|
||||
$this->tpl['price'] = $this->price;
|
||||
$this->tpl['price_min'] = $this->price_min;
|
||||
$this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type");
|
||||
|
||||
// VAT
|
||||
$this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,'');
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
// Status
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status);
|
||||
|
||||
//To Buy
|
||||
$statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No"));
|
||||
$this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy);
|
||||
|
||||
$this->tpl['description'] = $this->description;
|
||||
$this->tpl['note'] = $this->note;
|
||||
}
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
$head = product_prepare_head($this->object,$user);
|
||||
|
||||
$this->tpl['showrefnav'] = $form->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
|
||||
$this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
|
||||
$this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
|
||||
|
||||
// Accountancy sell code
|
||||
$this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
|
||||
$this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
|
||||
}
|
||||
|
||||
$this->tpl['finished'] = $this->object->finished;
|
||||
$this->tpl['ref'] = $this->object->ref;
|
||||
$this->tpl['label'] = $this->object->label;
|
||||
$this->tpl['id'] = $this->object->id;
|
||||
$this->tpl['type'] = $this->object->type;
|
||||
$this->tpl['note'] = $this->object->note;
|
||||
$this->tpl['seuil_stock_alerte'] = $this->object->seuil_stock_alerte;
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
// Title
|
||||
$this->tpl['title'] = $langs->trans("NewProduct");
|
||||
}
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
$this->tpl['title'] = $langs->trans('Modify').' '.$langs->trans('Product').' : '.$this->object->ref;
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
// Status
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]);
|
||||
|
||||
$statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy"));
|
||||
$this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]);
|
||||
|
||||
// Finished
|
||||
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||
$this->tpl['finished'] = $form->selectarray('finished',$statutarray,$this->object->finished);
|
||||
|
||||
// Weight
|
||||
$this->tpl['weight'] = $this->object->weight;
|
||||
$this->tpl['weight_units'] = $formproduct->load_measuring_units("weight_units","weight",$this->object->weight_units);
|
||||
|
||||
// Length
|
||||
$this->tpl['length'] = $this->object->length;
|
||||
$this->tpl['length_units'] = $formproduct->load_measuring_units("length_units","size",$this->object->length_units);
|
||||
|
||||
// Surface
|
||||
$this->tpl['surface'] = $this->object->surface;
|
||||
$this->tpl['surface_units'] = $formproduct->load_measuring_units("surface_units","surface",$this->object->surface_units);
|
||||
|
||||
// Volume
|
||||
$this->tpl['volume'] = $this->object->volume;
|
||||
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units","volume",$this->object->volume_units);
|
||||
}
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
// Status
|
||||
$this->tpl['status'] = $this->object->getLibStatut(2,0);
|
||||
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);
|
||||
|
||||
// Photo
|
||||
$this->tpl['nblignes'] = 4;
|
||||
if ($this->object->is_photo_available($conf->product->multidir_output[$this->object->entity]))
|
||||
{
|
||||
$this->tpl['photos'] = $this->object->show_photos($conf->product->multidir_output[$this->object->entity],1,1,0,0,0,80);
|
||||
}
|
||||
|
||||
// Nature
|
||||
$this->tpl['finished'] = $this->object->getLibFinished();
|
||||
|
||||
// Weight
|
||||
if ($this->object->weight != '')
|
||||
{
|
||||
$this->tpl['weight'] = $this->object->weight." ".measuring_units_string($this->object->weight_units,"weight");
|
||||
}
|
||||
|
||||
// Length
|
||||
if ($this->object->length != '')
|
||||
{
|
||||
$this->tpl['length'] = $this->object->length." ".measuring_units_string($this->object->length_units,"size");
|
||||
}
|
||||
|
||||
// Surface
|
||||
if ($this->object->surface != '')
|
||||
{
|
||||
$this->tpl['surface'] = $this->object->surface." ".measuring_units_string($this->object->surface_units,"surface");
|
||||
}
|
||||
|
||||
// Volume
|
||||
if ($this->object->volume != '')
|
||||
{
|
||||
$this->tpl['volume'] = $this->object->volume." ".measuring_units_string($this->object->volume_units,"volume");
|
||||
}
|
||||
|
||||
$this->tpl['fiche_end']=dol_get_fiche_end();
|
||||
}
|
||||
|
||||
if ($action == 'list')
|
||||
{
|
||||
$this->LoadListDatas($GLOBALS['limit'], $GLOBALS['offset'], $GLOBALS['sortfield'], $GLOBALS['sortorder']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch field list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function getFieldList()
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$this->field_list = array();
|
||||
|
||||
$sql = "SELECT rowid, name, alias, title, align, sort, search, enabled, rang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_field_list";
|
||||
$sql.= " WHERE element = '".$this->fieldListName."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " ORDER BY rang ASC";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$fieldlist = array();
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$fieldlist["id"] = $obj->rowid;
|
||||
$fieldlist["name"] = $obj->name;
|
||||
$fieldlist["alias"] = $obj->alias;
|
||||
$fieldlist["title"] = $langs->trans($obj->title);
|
||||
$fieldlist["align"] = $obj->align;
|
||||
$fieldlist["sort"] = $obj->sort;
|
||||
$fieldlist["search"] = $obj->search;
|
||||
$fieldlist["enabled"] = verifCond($obj->enabled);
|
||||
$fieldlist["order"] = $obj->rang;
|
||||
|
||||
array_push($this->field_list,$fieldlist);
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db,$sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch datas list
|
||||
*
|
||||
* @param int $limit Limit number of responses
|
||||
* @param int $offset Offset for first response
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order ('ASC' or 'DESC')
|
||||
* @return void
|
||||
*/
|
||||
function LoadListDatas($limit, $offset, $sortfield, $sortorder)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$this->getFieldList();
|
||||
|
||||
$this->list_datas = array();
|
||||
|
||||
//$_GET["sall"] = 'LL';
|
||||
// Clean parameters
|
||||
$sall=trim(isset($_GET["sall"])?$_GET["sall"]:$_POST["sall"]);
|
||||
|
||||
foreach($this->field_list as $field)
|
||||
{
|
||||
if ($field['enabled'])
|
||||
{
|
||||
$fieldname = "s".$field['alias'];
|
||||
$$fieldname = trim(isset($_GET[$fieldname])?$_GET[$fieldname]:$_POST[$fieldname]);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT DISTINCT ';
|
||||
|
||||
// Fields requiered
|
||||
$sql.= 'p.rowid, p.price_base_type, p.fk_product_type, p.seuil_stock_alerte';
|
||||
|
||||
// Fields not requiered
|
||||
foreach($this->field_list as $field)
|
||||
{
|
||||
if ($field['enabled'])
|
||||
{
|
||||
$sql.= ", ".$field['name']." as ".$field['alias'];
|
||||
}
|
||||
}
|
||||
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
$clause = '';
|
||||
$sql.= " AND (";
|
||||
foreach($this->field_list as $field)
|
||||
{
|
||||
if ($field['enabled'])
|
||||
{
|
||||
$sql.= $clause." ".$field['name']." LIKE '%".$this->db->escape($sall)."%'";
|
||||
if ($clause=='') $clause = ' OR';
|
||||
}
|
||||
}
|
||||
$sql.= ")";
|
||||
}
|
||||
|
||||
// Search fields
|
||||
foreach($this->field_list as $field)
|
||||
{
|
||||
if ($field['enabled'])
|
||||
{
|
||||
$fieldname = "s".$field['alias'];
|
||||
if (${$fieldname}) $sql.= " AND ".$field['name']." LIKE '%".$this->db->escape(${$fieldname})."%'";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0)
|
||||
{
|
||||
$sql.= " AND p.tosell = ".$this->db->escape($_GET["tosell"]);
|
||||
}
|
||||
if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0)
|
||||
{
|
||||
$sql.= " AND p.canvas = '".$this->db->escape($_GET["canvas"])."'";
|
||||
}
|
||||
$sql.= $this->db->order($sortfield,$sortorder);
|
||||
$sql.= $this->db->plimit($limit+1, $offset);
|
||||
//print $sql;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$datas = array();
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$datas["id"] = $obj->rowid;
|
||||
|
||||
foreach($this->field_list as $field)
|
||||
{
|
||||
if ($field['enabled'])
|
||||
{
|
||||
$alias = $field['alias'];
|
||||
|
||||
if ($alias == 'ref')
|
||||
{
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->$alias;
|
||||
$this->type = $obj->fk_product_type;
|
||||
$datas[$alias] = $this->getNomUrl(1,'',24);
|
||||
}
|
||||
else if ($alias == 'stock')
|
||||
{
|
||||
$this->load_stock();
|
||||
if ($this->stock_reel < $obj->seuil_stock_alerte) $datas[$alias] = $this->stock_reel.' '.img_warning($langs->trans("StockTooLow"));
|
||||
else $datas[$alias] = $this->stock_reel;
|
||||
}
|
||||
else if ($alias == 'label') $datas[$alias] = dol_trunc($obj->$alias,40);
|
||||
else if (preg_match('/price/i',$alias)) $datas[$alias] = price($obj->$alias);
|
||||
else if ($alias == 'datem') $datas[$alias] = dol_print_date($this->db->jdate($obj->$alias),'day');
|
||||
else if ($alias == 'status') $datas[$alias] = $this->LibStatut($obj->$alias,5);
|
||||
else $datas[$alias] = $obj->$alias;
|
||||
}
|
||||
}
|
||||
|
||||
array_push($this->list_datas,$datas);
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -13,15 +13,20 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<?php print_fiche_titre($this->control->tpl['title']); ?>
|
||||
<?php print_fiche_titre($langs->trans("Product")); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
||||
<?php dol_htmloutput_errors($object->error,$object->errors); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($GLOBALS['mesg'],$GLOBALS['mesgs']); ?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
|
||||
@ -33,66 +38,62 @@
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $this->control->tpl['ref']; ?>">
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $object->ref; ?>">
|
||||
<?php if ($_error == 1) echo $langs->trans("RefAlreadyExists"); ?>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $this->control->tpl['label']; ?>"></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $object->label; ?>"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status']; ?></td>
|
||||
<td><?php echo $form->selectarray('statut',$statutarray,$object->status); ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status_buy']; ?></td>
|
||||
<td><?php echo $form->selectarray('statut_buy',$statutarray,$object->status_tobuy); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if ($conf->stock->enabled) { ?>
|
||||
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
|
||||
<input name="seuil_stock_alerte" size="4" value="<?php echo $this->control->tpl['seuil_stock_alerte']; ?>">
|
||||
<input name="seuil_stock_alerte" size="4" value="<?php echo $object->seuil_stock_alerte; ?>">
|
||||
</td></tr>
|
||||
<?php } else { ?>
|
||||
<input name="seuil_stock_alerte" type="hidden" value="0">
|
||||
<?php } ?>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
|
||||
<?php echo $this->control->tpl['textarea_description']; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Nature"); ?></td><td>
|
||||
<?php echo $this->control->tpl['finished']; ?>
|
||||
<?php echo $object->finished; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Weight"); ?></td><td>
|
||||
<input name="weight" size="4" value="<?php echo $this->control->tpl['weight']; ?>">
|
||||
<?php echo $this->control->tpl['weight_units']; ?>
|
||||
<input name="weight" size="4" value="<?php echo $object->weight; ?>">
|
||||
<?php echo $object->weight_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Length"); ?></td><td>
|
||||
<input name="size" size="4" value="<?php echo $this->control->tpl['length']; ?>">
|
||||
<?php echo $this->control->tpl['length_units']; ?>
|
||||
<input name="size" size="4" value="<?php echo $object->length; ?>">
|
||||
<?php echo $object->length_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Surface"); ?></td><td>
|
||||
<input name="surface" size="4" value="<?php echo $this->control->tpl['surface']; ?>">
|
||||
<?php echo $this->control->tpl['surface_units']; ?>
|
||||
<input name="surface" size="4" value="<?php echo $object->surface; ?>">
|
||||
<?php echo $object->surface_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Volume"); ?></td><td>
|
||||
<input name="volume" size="4" value="<?php echo $this->control->tpl['volume']; ?>">
|
||||
<?php echo $this->control->tpl['volume_units']; ?>
|
||||
<input name="volume" size="4" value="<?php echo $object->volume; ?>">
|
||||
<?php echo $object->volume_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Hidden"); ?></td>
|
||||
<td><?php echo $this->control->tpl['hidden']; ?></td></tr>
|
||||
<td><?php echo $object->hidden; ?></td></tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
|
||||
<?php echo $this->control->tpl['textarea_note']; ?>
|
||||
<?php echo $object->textarea_note; ?>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
@ -103,16 +104,16 @@
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr><td><?php echo $langs->trans("SellingPrice"); ?></td>
|
||||
<td><input name="price" size="10" value="<?php echo $this->control->tpl['price']; ?>">
|
||||
<?php echo $this->control->tpl['price_base_type']; ?>
|
||||
<td><input name="price" size="10" value="<?php echo $object->price; ?>">
|
||||
<?php echo $object->price_base_type; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("MinPrice"); ?></td>
|
||||
<td><input name="price_min" size="10" value="<?php echo $this->control->tpl['price_min']; ?>">
|
||||
<td><input name="price_min" size="10" value="<?php echo $object->price_min; ?>">
|
||||
</td></tr>
|
||||
|
||||
<tr><td width="20%"><?php echo $langs->trans("VATRate"); ?></td><td>
|
||||
<?php echo $this->control->tpl['tva_tx']; ?>
|
||||
<?php echo $object->tva_tx; ?>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
@ -13,80 +13,84 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<?php
|
||||
print_fiche_titre($this->control->tpl['title']);
|
||||
print_fiche_titre($langs->trans("Product"));
|
||||
|
||||
dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']);
|
||||
dol_htmloutput_errors($object->error,$object->errors);
|
||||
?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
|
||||
<input type="hidden" name="action" value="update">
|
||||
<input type="hidden" name="id" value="<?php echo $this->control->tpl['id']; ?>">
|
||||
<input type="hidden" name="canvas" value="<?php echo $this->control->tpl['canvas']; ?>">
|
||||
<input type="hidden" name="id" value="<?php echo $object->id; ?>">
|
||||
<input type="hidden" name="canvas" value="<?php echo $object->canvas; ?>">
|
||||
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $this->control->tpl['ref']; ?>">
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $object->ref; ?>">
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $this->control->tpl['label']; ?>"></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $object->label; ?>"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status"); ?></td>
|
||||
<td><?php echo $this->control->tpl['status']; ?></td>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
|
||||
<td><?php echo $form->selectarray('statut',$statutarray,$object->status); ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
|
||||
<td><?php echo $form->selectarray('statut_buy',$statutarray,$object->status_tobuy); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if ($conf->stock->enabled) { ?>
|
||||
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
|
||||
<input name="seuil_stock_alerte" size="4" value="<?php echo $this->control->tpl['seuil_stock_alerte']; ?>">
|
||||
<input name="seuil_stock_alerte" size="4" value="<?php echo $object->seuil_stock_alerte; ?>">
|
||||
</td></tr>
|
||||
<?php } else { ?>
|
||||
<input name="seuil_stock_alerte" type="hidden" value="0">
|
||||
<?php } ?>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
|
||||
<?php echo $this->control->tpl['textarea_description']; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Nature"); ?></td><td>
|
||||
<?php echo $this->control->tpl['finished']; ?>
|
||||
<?php echo $object->finished; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Weight"); ?></td><td>
|
||||
<input name="weight" size="4" value="<?php echo $this->control->tpl['weight']; ?>">
|
||||
<?php echo $this->control->tpl['weight_units']; ?>
|
||||
<input name="weight" size="4" value="<?php echo $object->weight; ?>">
|
||||
<?php echo $object->weight_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Length"); ?></td><td>
|
||||
<input name="size" size="4" value="<?php echo $this->control->tpl['length']; ?>">
|
||||
<?php echo $this->control->tpl['length_units']; ?>
|
||||
<input name="size" size="4" value="<?php echo $object->length; ?>">
|
||||
<?php echo $object->length_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Surface"); ?></td><td>
|
||||
<input name="surface" size="4" value="<?php echo $this->control->tpl['surface']; ?>">
|
||||
<?php echo $this->control->tpl['surface_units']; ?>
|
||||
<input name="surface" size="4" value="<?php echo $object->surface; ?>">
|
||||
<?php echo $object->surface_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Volume"); ?></td><td>
|
||||
<input name="volume" size="4" value="<?php echo $this->control->tpl['volume']; ?>">
|
||||
<?php echo $this->control->tpl['volume_units']; ?>
|
||||
<input name="volume" size="4" value="<?php echo $object->volume; ?>">
|
||||
<?php echo $object->volume_units; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
|
||||
<?php echo $this->control->tpl['textarea_note']; ?>
|
||||
<?php echo $object->textarea_note; ?>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
@ -13,29 +13,30 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
<?php echo $this->control->tpl['showhead']; ?>
|
||||
<?php echo $langs->trans("Product"); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
||||
<?php dol_htmloutput_errors($object->error,$object->errors); ?>
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr>
|
||||
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['showrefnav']; ?></td>
|
||||
<td colspan="2"><?php echo $object->ref; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Label") ?></td>
|
||||
<td><?php echo $this->control->tpl['label']; ?></td>
|
||||
<td><?php echo $object->label; ?></td>
|
||||
|
||||
<?php if ($this->control->tpl['photos']) { ?>
|
||||
<td valign="middle" align="center" width="30%" rowspan="<?php echo $this->control->tpl['nblignes']; ?>">
|
||||
<?php echo $this->control->tpl['photos']; ?>
|
||||
<?php if ($object->photos) { ?>
|
||||
<td valign="middle" align="center" width="30%" rowspan="<?php echo $object->nblignes; ?>">
|
||||
<?php echo $object->photos; ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
@ -43,51 +44,49 @@
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status']; ?></td>
|
||||
<td><?php echo $object->status; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status_buy']; ?></td>
|
||||
<td><?php echo $object->status_buy; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><?php echo $langs->trans("Description"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['description']; ?></td>
|
||||
<td colspan="2"><?php echo $object->description; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Nature"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['finished']; ?></td>
|
||||
<td colspan="2"><?php echo $object->finished; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Weight"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['weight']; ?></td>
|
||||
<td colspan="2"><?php echo $object->weight; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Length"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['length']; ?></td>
|
||||
<td colspan="2"><?php echo $object->length; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Surface"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['surface']; ?></td>
|
||||
<td colspan="2"><?php echo $object->surface; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Volume"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['volume']; ?></td>
|
||||
<td colspan="2"><?php echo $object->volume; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><?php echo $langs->trans("Note"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['note']; ?></td>
|
||||
<td colspan="2"><?php echo $object->note; ?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php echo $this->control->tpl['showend']; ?>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -1,382 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/product/canvas/service/actions_card_service.class.php
|
||||
* \ingroup service
|
||||
* \brief Fichier de la classe des services par defaut
|
||||
*/
|
||||
include_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
|
||||
|
||||
/**
|
||||
* \class ActionsCardService
|
||||
* \brief Class with controller methods for product canvas
|
||||
*/
|
||||
class ActionsCardService extends Product
|
||||
{
|
||||
var $targetmodule;
|
||||
var $canvas;
|
||||
var $card;
|
||||
|
||||
//! Template container
|
||||
var $tpl = array();
|
||||
|
||||
// List of fiels for action=list
|
||||
var $field_list =array();
|
||||
public $list_datas = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $DB Handler acces base de donnees
|
||||
* @param string $targetmodule Name of directory of module where canvas is stored
|
||||
* @param string $canvas Name of canvas
|
||||
* @param string $card Name of tab (sub-canvas)
|
||||
*/
|
||||
function ActionsCardService($DB,$targetmodule,$canvas,$card)
|
||||
{
|
||||
$this->db = $DB;
|
||||
$this->targetmodule = $targetmodule;
|
||||
$this->canvas = $canvas;
|
||||
$this->card = $card;
|
||||
|
||||
$this->module = "service";
|
||||
$this->name = "service";
|
||||
$this->definition = "Services canvas";
|
||||
$this->fieldListName = "product_service";
|
||||
$this->next_prev_filter = "canvas='service'";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign custom values for canvas (for example into this->tpl to be used by templates)
|
||||
*
|
||||
* @param string &$action Type of action
|
||||
* @param string $id Id of object
|
||||
* @param string $ref Ref of object
|
||||
* @return void
|
||||
*/
|
||||
function assign_values(&$action, $id=0, $ref='')
|
||||
{
|
||||
global $conf, $langs, $user, $mysoc, $canvas;
|
||||
global $form, $formproduct;
|
||||
|
||||
$tmpobject = new Product($this->db);
|
||||
if (! empty($id) || ! empty($ref)) $tmpobject->fetch($id,$ref);
|
||||
$this->object = $tmpobject;
|
||||
|
||||
//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
|
||||
$this->tpl['canvas'] = $this->canvas;
|
||||
|
||||
// id
|
||||
$this->tpl['id'] = $this->id;
|
||||
|
||||
// Ref
|
||||
$this->tpl['ref'] = $this->ref;
|
||||
|
||||
// Label
|
||||
$this->tpl['label'] = $this->libelle;
|
||||
|
||||
// Description
|
||||
$this->tpl['description'] = nl2br($this->description);
|
||||
|
||||
// Statut
|
||||
$this->tpl['status'] = $this->getLibStatut(2);
|
||||
|
||||
// Note
|
||||
$this->tpl['note'] = nl2br($this->note);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
// Price
|
||||
$this->tpl['price'] = $this->price;
|
||||
$this->tpl['price_min'] = $this->price_min;
|
||||
$this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type");
|
||||
|
||||
// VAT
|
||||
$this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,'');
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
// Status
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$this->tpl['status'] = $form->selectarray('statut',$statutarray,$this->status);
|
||||
|
||||
//To Buy
|
||||
$statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No"));
|
||||
$this->tpl['tobuy'] = $form->selectarray('tobuy',$statutarray,$this->status_buy);
|
||||
|
||||
$this->tpl['description'] = $this->description;
|
||||
$this->tpl['note'] = $this->note;
|
||||
}
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
$head = product_prepare_head($this->object,$user);
|
||||
|
||||
$this->tpl['showrefnav'] = $form->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
|
||||
$this->tpl['accountancyBuyCodeKey'] = $form->editfieldkey("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
|
||||
$this->tpl['accountancyBuyCodeVal'] = $form->editfieldval("ProductAccountancyBuyCode",'productaccountancycodesell',$this->accountancy_code_sell,$this,$user->rights->produit->creer);
|
||||
|
||||
// Accountancy sell code
|
||||
$this->tpl['accountancySellCodeKey'] = $form->editfieldkey("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
|
||||
$this->tpl['accountancySellCodeVal'] = $form->editfieldval("ProductAccountancySellCode",'productaccountancycodebuy',$this->accountancy_code_buy,$this,$user->rights->produit->creer);
|
||||
}
|
||||
|
||||
$this->tpl['finished'] = $this->object->finished;
|
||||
$this->tpl['ref'] = $this->object->ref;
|
||||
$this->tpl['label'] = $this->object->label;
|
||||
$this->tpl['id'] = $this->object->id;
|
||||
$this->tpl['type'] = $this->object->type;
|
||||
$this->tpl['note'] = $this->object->note;
|
||||
$this->tpl['seuil_stock_alerte'] = $this->object->seuil_stock_alerte;
|
||||
|
||||
// Duration
|
||||
$this->tpl['duration_value'] = $this->object->duration_value;
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
// Title
|
||||
$this->tpl['title'] = $langs->trans("NewService");
|
||||
}
|
||||
|
||||
if ($action == 'edit')
|
||||
{
|
||||
$this->tpl['title'] = $langs->trans('Modify').' '.$langs->trans('Service').' : '.$this->object->ref;
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
// Status
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$this->tpl['status'] = $form->selectarray('statut',$statutarray,$_POST["statut"]);
|
||||
|
||||
$statutarray=array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy"));
|
||||
$this->tpl['status_buy'] = $form->selectarray('statut_buy',$statutarray,$_POST["statut_buy"]);
|
||||
|
||||
// Duration unit
|
||||
// TODO creer fonction
|
||||
$duration_unit = '<input name="duration_unit" type="radio" value="h"'.($this->object->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour");
|
||||
$duration_unit.= ' ';
|
||||
$duration_unit.= '<input name="duration_unit" type="radio" value="d"'.($this->object->duration_unit=='d'?' checked':'').'>'.$langs->trans("Day");
|
||||
$duration_unit.= ' ';
|
||||
$duration_unit.= '<input name="duration_unit" type="radio" value="w"'.($this->object->duration_unit=='w'?' checked':'').'>'.$langs->trans("Week");
|
||||
$duration_unit.= ' ';
|
||||
$duration_unit.= '<input name="duration_unit" type="radio" value="m"'.($this->object->duration_unit=='m'?' checked':'').'>'.$langs->trans("Month");
|
||||
$duration_unit.= ' ';
|
||||
$duration_unit.= '<input name="duration_unit" type="radio" value="y"'.($this->object->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
|
||||
$this->tpl['duration_unit'] = $duration_unit;
|
||||
}
|
||||
|
||||
if ($action == 'view')
|
||||
{
|
||||
// Status
|
||||
$this->tpl['status'] = $this->object->getLibStatut(2,0);
|
||||
$this->tpl['status_buy'] = $this->object->getLibStatut(2,1);
|
||||
|
||||
// Photo
|
||||
$this->tpl['nblignes'] = 4;
|
||||
if ($this->object->is_photo_available($conf->service->multidir_output[$this->object->entity]))
|
||||
{
|
||||
$this->tpl['photos'] = $this->object->show_photos($conf->service->multidir_output[$this->object->entity],1,1,0,0,0,80);
|
||||
}
|
||||
|
||||
// Duration
|
||||
if ($this->object->duration_value > 1)
|
||||
{
|
||||
$dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years"));
|
||||
}
|
||||
else if ($this->object->duration_value > 0)
|
||||
{
|
||||
$dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year"));
|
||||
}
|
||||
$this->tpl['duration_unit'] = $langs->trans($dur[$this->object->duration_unit]);
|
||||
|
||||
$this->tpl['fiche_end']=dol_get_fiche_end();
|
||||
}
|
||||
|
||||
if ($action == 'list')
|
||||
{
|
||||
$this->LoadListDatas($GLOBALS['limit'], $GLOBALS['offset'], $GLOBALS['sortfield'], $GLOBALS['sortorder']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch field list
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function getFieldList()
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$this->field_list = array();
|
||||
|
||||
$sql = "SELECT rowid, name, alias, title, align, sort, search, enabled, rang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_field_list";
|
||||
$sql.= " WHERE element = '".$this->fieldListName."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " ORDER BY rang ASC";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$fieldlist = array();
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$fieldlist["id"] = $obj->rowid;
|
||||
$fieldlist["name"] = $obj->name;
|
||||
$fieldlist["alias"] = $obj->alias;
|
||||
$fieldlist["title"] = $langs->trans($obj->title);
|
||||
$fieldlist["align"] = $obj->align;
|
||||
$fieldlist["sort"] = $obj->sort;
|
||||
$fieldlist["search"] = $obj->search;
|
||||
$fieldlist["enabled"] = verifCond($obj->enabled);
|
||||
$fieldlist["order"] = $obj->rang;
|
||||
|
||||
array_push($this->field_list,$fieldlist);
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db,$sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch datas list
|
||||
*
|
||||
* @param int $limit Limit number of responses
|
||||
* @param int $offset Offset for first response
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order ('ASC' or 'DESC')
|
||||
* @return void
|
||||
*/
|
||||
function LoadListDatas($limit, $offset, $sortfield, $sortorder)
|
||||
{
|
||||
global $conf;
|
||||
global $search_categ,$sall,$sref,$sbarcode,$snom,$catid;
|
||||
|
||||
$this->getFieldList();
|
||||
|
||||
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,';
|
||||
$sql.= ' p.fk_product_type, p.tms as datem,';
|
||||
$sql.= ' p.duration, p.tosell as statut, p.seuil_stock_alerte';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p';
|
||||
// We'll need this table joined to the select in order to filter by categ
|
||||
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp";
|
||||
if ($_GET["fourn_id"] > 0)
|
||||
{
|
||||
$fourn_id = $_GET["fourn_id"];
|
||||
$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
}
|
||||
$sql.= " WHERE p.entity IN (".getEntity('product', 1).")";
|
||||
if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ
|
||||
if ($sall)
|
||||
{
|
||||
$sql.= " AND (p.ref LIKE '%".$this->db->escape($sall)."%' OR p.label LIKE '%".$this->db->escape($sall)."%' OR p.description LIKE '%".$this->db->escape($sall)."%' OR p.note LIKE '%".$this->db->escape($sall)."%')";
|
||||
}
|
||||
if ($sref) $sql.= " AND p.ref LIKE '%".$sref."%'";
|
||||
if ($sbarcode) $sql.= " AND p.barcode LIKE '%".$sbarcode."%'";
|
||||
if ($snom) $sql.= " AND p.label LIKE '%".$this->db->escape($snom)."%'";
|
||||
if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0)
|
||||
{
|
||||
$sql.= " AND p.tosell = ".$this->db->escape($_GET["tosell"]);
|
||||
}
|
||||
if (isset($_GET["canvas"]) && dol_strlen($_GET["canvas"]) > 0)
|
||||
{
|
||||
$sql.= " AND p.canvas = '".$this->db->escape($_GET["canvas"])."'";
|
||||
}
|
||||
if($catid)
|
||||
{
|
||||
$sql.= " AND cp.fk_categorie = ".$catid;
|
||||
}
|
||||
if ($fourn_id > 0)
|
||||
{
|
||||
$sql.= " AND p.rowid = pfp.fk_product AND pfp.fk_soc = ".$fourn_id;
|
||||
}
|
||||
// Insert categ filter
|
||||
if ($search_categ)
|
||||
{
|
||||
$sql .= " AND cp.fk_categorie = ".$this->db->escape($search_categ);
|
||||
}
|
||||
$sql.= $this->db->order($sortfield,$sortorder);
|
||||
$sql.= $this->db->plimit($limit+1, $offset);
|
||||
|
||||
$this->list_datas = array();
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$datas = array();
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$datas["id"] = $obj->rowid;
|
||||
$datas["ref"] = $obj->ref;
|
||||
$datas["label"] = $obj->label;
|
||||
$datas["barcode"] = $obj->barcode;
|
||||
$datas["statut"] = $obj->statut;
|
||||
|
||||
array_push($this->list_datas,$datas);
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -15,14 +15,20 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
<!-- BEGIN PHP TEMPLATE CREATE.TPL -->
|
||||
|
||||
<?php print_fiche_titre($this->control->tpl['title']); ?>
|
||||
<?php print_fiche_titre($langs->trans("Service")); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($GLOBALS['mesg'],$GLOBALS['mesgs']); ?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
|
||||
<input type="hidden" name="action" value="add">
|
||||
@ -33,39 +39,35 @@
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $this->object->tpl['ref']; ?>">
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $object->ref; ?>">
|
||||
<?php if ($_error == 1) echo $langs->trans("RefAlreadyExists"); ?>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $this->object->tpl['label']; ?>"></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $object->label; ?>"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status']; ?></td>
|
||||
<td><?php echo $form->selectarray('statut',$statutarray,$object->status); ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status_buy']; ?></td>
|
||||
<td><?php echo $form->selectarray('statut_buy',$statutarray,$object->status_tobuy); ?></td>
|
||||
</tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
|
||||
<?php echo $this->object->tpl['textarea_description']; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Duration"); ?></td>
|
||||
<td><input name="duration_value" size="6" maxlength="5" value="<?php echo $this->object->tpl['duration_value']; ?>">
|
||||
<?php echo $this->object->tpl['duration_unit']; ?>
|
||||
<td><input name="duration_value" size="6" maxlength="5" value="<?php echo $object->duration_value; ?>">
|
||||
<?php echo $object->duration_unit; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Hidden"); ?></td>
|
||||
<td><?php echo $this->object->tpl['hidden']; ?></td></tr>
|
||||
<td><?php echo $object->hidden; ?></td></tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
|
||||
<?php echo $this->object->tpl['textarea_note']; ?>
|
||||
<?php echo $object->textarea_note; ?>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
@ -76,16 +78,16 @@
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr><td><?php echo $langs->trans("SellingPrice"); ?></td>
|
||||
<td><input name="price" size="10" value="<?php echo $this->object->tpl['price']; ?>">
|
||||
<?php echo $this->object->tpl['price_base_type']; ?>
|
||||
<td><input name="price" size="10" value="<?php echo $object->price; ?>">
|
||||
<?php echo $object->price_base_type; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("MinPrice"); ?></td>
|
||||
<td><input name="price_min" size="10" value="<?php echo $this->object->tpl['price_min']; ?>">
|
||||
<td><input name="price_min" size="10" value="<?php echo $object->price_min; ?>">
|
||||
</td></tr>
|
||||
|
||||
<tr><td width="20%"><?php echo $langs->trans("VATRate"); ?></td><td>
|
||||
<?php echo $this->object->tpl['tva_tx']; ?>
|
||||
<?php echo $object->tva_tx; ?>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
@ -13,57 +13,57 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
<!-- BEGIN PHP TEMPLATE EDIT.TPL -->
|
||||
|
||||
<?php echo $this->object->tpl['title']; ?>
|
||||
<?php
|
||||
print_fiche_titre($langs->trans("Service"));
|
||||
|
||||
<?php if ($mesg) { ?>
|
||||
<br><div class="error"><?php echo $mesg; ?></div><br>
|
||||
<?php } ?>
|
||||
dol_htmloutput_errors($object->error,$object->errors);
|
||||
?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
|
||||
<input type="hidden" name="action" value="update">
|
||||
<input type="hidden" name="id" value="<?php echo $this->object->tpl['id']; ?>">
|
||||
<input type="hidden" name="canvas" value="<?php echo $this->object->tpl['canvas']; ?>">
|
||||
<input type="hidden" name="id" value="<?php echo $object->id; ?>">
|
||||
<input type="hidden" name="canvas" value="<?php echo $object->canvas; ?>">
|
||||
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired" width="20%"><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $this->object->tpl['ref']; ?>">
|
||||
<td><input name="ref" size="40" maxlength="32" value="<?php echo $object->ref; ?>">
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $this->object->tpl['label']; ?>"></td>
|
||||
<td><input name="libelle" size="40" value="<?php echo $object->label; ?>"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status"); ?></td>
|
||||
<td><?php echo $this->object->tpl['status']; ?></td>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
|
||||
<td><?php echo $form->selectarray('statut',$statutarray,$object->status); ?></td>
|
||||
</tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
|
||||
<?php if (! $this->object->tpl['textarea_description']) {
|
||||
$this->object->tpl['doleditor_description']->Create();
|
||||
}else{
|
||||
echo $this->object->tpl['textarea_description'];
|
||||
}?>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td class="fieldrequired"><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
|
||||
<td><?php echo $form->selectarray('statut_buy',$statutarray,$object->status_tobuy); ?></td>
|
||||
</tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Duration"); ?></td>
|
||||
<td><input name="duration_value" size="6" maxlength="5" value="<?php echo $this->object->tpl['duration_value']; ?>">
|
||||
<?php echo $this->object->tpl['duration_unit']; ?>
|
||||
<td><input name="duration_value" size="6" maxlength="5" value="<?php echo $object->duration_value; ?>">
|
||||
<?php echo $object->duration_unit; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
|
||||
<?php echo $this->object->tpl['textarea_note']; ?>
|
||||
<?php echo $object->textarea_note; ?>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
@ -13,29 +13,30 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
$object=$GLOBALS['object'];
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
<?php echo $this->control->tpl['showhead']; ?>
|
||||
<!-- BEGIN PHP TEMPLATE VIEW.TPL -->
|
||||
<?php echo $langs->trans("Service"); ?>
|
||||
|
||||
<?php dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?>
|
||||
<?php dol_htmloutput_errors($object->error,$object->errors); ?>
|
||||
|
||||
<table class="border allwidth">
|
||||
|
||||
<tr>
|
||||
<td width="15%"><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['showrefnav']; ?></td>
|
||||
<td colspan="2"><?php echo $object->ref; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Label") ?></td>
|
||||
<td><?php echo $this->control->tpl['label']; ?></td>
|
||||
<td><?php echo $object->label; ?></td>
|
||||
|
||||
<?php if ($this->control->tpl['photos']) { ?>
|
||||
<td valign="middle" align="center" width="30%" rowspan="<?php echo $this->control->tpl['nblignes']; ?>">
|
||||
<?php echo $this->control->tpl['photos']; ?>
|
||||
<?php if ($object->photos) { ?>
|
||||
<td valign="middle" align="center" width="30%" rowspan="<?php echo $object->nblignes; ?>">
|
||||
<?php echo $object->photos; ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
@ -43,35 +44,29 @@
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Status").' ('.$langs->trans("Sell").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status']; ?></td>
|
||||
<td><?php echo $object->status; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Status").' ('.$langs->trans("Buy").')'; ?></td>
|
||||
<td><?php echo $this->control->tpl['status_buy']; ?></td>
|
||||
<td><?php echo $object->status_buy; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><?php echo $langs->trans("Description"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['description']; ?></td>
|
||||
<td colspan="2"><?php echo $object->description; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Duration"); ?></td>
|
||||
<td><?php echo $this->control->tpl['duration_value']; ?>
|
||||
<?php echo $this->control->tpl['duration_unit']; ?>
|
||||
<td><?php echo $object->duration_value; ?>
|
||||
<?php echo $object->duration_unit; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $langs->trans("Hidden"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['hidden']; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><?php echo $langs->trans("Note"); ?></td>
|
||||
<td colspan="2"><?php echo $this->control->tpl['note']; ?></td>
|
||||
<td colspan="2"><?php echo $object->note; ?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php echo $this->control->tpl['showend']; ?>
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -286,7 +286,8 @@ if (empty($reshook))
|
||||
{
|
||||
if ($object->update($object->id, $user) > 0)
|
||||
{
|
||||
$action = '';
|
||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -300,6 +301,7 @@ if (empty($reshook))
|
||||
$mesg = $langs->trans("ErrorProductBadRefOrLabel");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -664,7 +666,6 @@ llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl);
|
||||
|
||||
$form = new Form($db);
|
||||
$formproduct = new FormProduct($db);
|
||||
$object=new Product($db);
|
||||
|
||||
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
@ -672,12 +673,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if (! $objcanvas->hasActions() && ($id || $ref))
|
||||
if (empty($object->error) && ($id || $ref))
|
||||
{
|
||||
$object = new Product($db);
|
||||
$object->fetch($id, $ref); // For use with "pure canvas" (canvas that contains templates only)
|
||||
$object->fetch($id, $ref);
|
||||
}
|
||||
$objcanvas->assign_values($action, $object->id, $ref); // Set value for templates
|
||||
$objcanvas->assign_values($action, $object->id, $ref); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
}
|
||||
else
|
||||
|
||||
@ -478,10 +478,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
// -----------------------------------------
|
||||
// When used with CANVAS
|
||||
// -----------------------------------------
|
||||
if (! $objcanvas->hasActions() && $socid)
|
||||
if (empty($object->error) && $socid)
|
||||
{
|
||||
$object = new Societe($db);
|
||||
$object->fetch($socid); // For use with "pure canvas" (canvas that contains templates only)
|
||||
$object->fetch($socid);
|
||||
}
|
||||
$objcanvas->assign_values($action, $socid); // Set value for templates
|
||||
$objcanvas->display_canvas($action); // Show template
|
||||
|
||||
Loading…
Reference in New Issue
Block a user