Works on product canvas and templates
!! WARNING : not stable !!
This commit is contained in:
parent
ea691a9e31
commit
16446edca4
@ -1513,16 +1513,29 @@ class Form
|
||||
print '</select>';
|
||||
if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Selection HT ou TTC
|
||||
* \param selected Id pre-selectionne
|
||||
* \param htmlname Nom de la zone select
|
||||
*/
|
||||
function select_PriceBaseType($selected='',$htmlname='price_base_type')
|
||||
{
|
||||
print $this->load_PriceBaseType($selected,$htmlname);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Selection HT ou TTC
|
||||
* \param selected Id pre-selectionne
|
||||
* \param htmlname Nom de la zone select
|
||||
*/
|
||||
function load_PriceBaseType($selected='',$htmlname='price_base_type')
|
||||
{
|
||||
global $langs;
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
|
||||
$return='';
|
||||
|
||||
$return.= '<select class="flat" name="'.$htmlname.'">';
|
||||
$options = array(
|
||||
'HT'=>$langs->trans("HT"),
|
||||
'TTC'=>$langs->trans("TTC")
|
||||
@ -1531,15 +1544,17 @@ class Form
|
||||
{
|
||||
if ($selected == $id)
|
||||
{
|
||||
print '<option value="'.$id.'" selected="true">'.$value;
|
||||
$return.= '<option value="'.$id.'" selected="true">'.$value;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$id.'">'.$value;
|
||||
$return.= '<option value="'.$id.'">'.$value;
|
||||
}
|
||||
print '</option>';
|
||||
$return.= '</option>';
|
||||
}
|
||||
print '</select>';
|
||||
$return.= '</select>';
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2191,8 +2206,7 @@ class Form
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Output an HTML select vat rate
|
||||
* \param name Nom champ html
|
||||
@ -2208,8 +2222,30 @@ class Form
|
||||
* Sinon la TVA proposee par defaut=0. Fin de regle.
|
||||
*/
|
||||
function select_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0)
|
||||
{
|
||||
print $this->load_tva($name, $selectedrate, $societe_vendeuse, $societe_acheteuse, $taux_produit, $info_bits);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Output an HTML select vat rate
|
||||
* \param name Nom champ html
|
||||
* \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage.
|
||||
* \param societe_vendeuse Objet societe vendeuse
|
||||
* \param societe_acheteuse Objet societe acheteuse
|
||||
* \param taux_produit Taux par defaut du produit vendu
|
||||
* \param info_bits Miscellanous information on line
|
||||
* \remarks Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
|
||||
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
|
||||
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
|
||||
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle.
|
||||
* Sinon la TVA proposee par defaut=0. Fin de regle.
|
||||
*/
|
||||
function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0)
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
|
||||
$return='';
|
||||
|
||||
$txtva=array();
|
||||
$libtva=array();
|
||||
@ -2225,13 +2261,13 @@ class Form
|
||||
{
|
||||
if ($societe_vendeuse->id == $mysoc->id)
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorYourCountryIsNotDefined").'</div>';
|
||||
$return.= '<font class="error">'.$langs->trans("ErrorYourCountryIsNotDefined").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorSupplierCountryIsNotDefined").'</div>';
|
||||
$return.= '<font class="error">'.$langs->trans("ErrorSupplierCountryIsNotDefined").'</div>';
|
||||
}
|
||||
return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
if (is_object($societe_vendeuse))
|
||||
@ -2274,12 +2310,12 @@ class Form
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorNoVATRateDefinedForSellerCountry",$code_pays).'</font>';
|
||||
$return.= '<font class="error">'.$langs->trans("ErrorNoVATRateDefinedForSellerCountry",$code_pays).'</font>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$this->db->error().'</font>';
|
||||
$return.= '<font class="error">'.$this->db->error().'</font>';
|
||||
}
|
||||
|
||||
// Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
|
||||
@ -2299,28 +2335,30 @@ class Form
|
||||
|
||||
if (sizeof($txtva))
|
||||
{
|
||||
print '<select class="flat" name="'.$name.'">';
|
||||
$return.= '<select class="flat" name="'.$name.'">';
|
||||
|
||||
for ($i = 0 ; $i < $nbdetaux ; $i++)
|
||||
{
|
||||
//print "xxxxx".$txtva[$i]."-".$nprtva[$i];
|
||||
print '<option value="'.$txtva[$i];
|
||||
print $nprtva[$i] ? '*': '';
|
||||
print '"';
|
||||
$return.= '<option value="'.$txtva[$i];
|
||||
$return.= $nprtva[$i] ? '*': '';
|
||||
$return.= '"';
|
||||
if ($txtva[$i] == $defaulttx && $nprtva[$i] == $defaultnpr)
|
||||
{
|
||||
print ' selected="true"';
|
||||
$return.= ' selected="true"';
|
||||
}
|
||||
print '>'.vatrate($libtva[$i]);
|
||||
print $nprtva[$i] ? ' *': '';
|
||||
print '</option>';
|
||||
$return.= '>'.vatrate($libtva[$i]);
|
||||
$return.= $nprtva[$i] ? ' *': '';
|
||||
$return.= '</option>';
|
||||
|
||||
$this->tva_taux_value[$i] = $txtva[$i];
|
||||
$this->tva_taux_libelle[$i] = $libtva[$i];
|
||||
$this->tva_taux_npr[$i] = $nprtva[$i];
|
||||
}
|
||||
print '</select>';
|
||||
$return.= '</select>';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2028,6 +2028,19 @@ function print_titre($titre)
|
||||
print '<div class="titre">'.$titre.'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Show a title with picto
|
||||
* \param titre Title to show
|
||||
* \param mesg Added message to show on right
|
||||
* \param picto Icon to use before title (should be a 32x32 transparent png file)
|
||||
* \param pictoisfullpath 1=Icon name is a full absolute url of image
|
||||
* \param id To force an id on html objects
|
||||
*/
|
||||
function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
||||
{
|
||||
print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Load a title with picto
|
||||
* \param titre Title to show
|
||||
@ -2060,19 +2073,6 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Show a title with picto
|
||||
* \param titre Title to show
|
||||
* \param mesg Added message to show on right
|
||||
* \param picto Icon to use before title (should be a 32x32 transparent png file)
|
||||
* \param pictoisfullpath 1=Icon name is a full absolute url of image
|
||||
* \param id To force an id on html objects
|
||||
*/
|
||||
function print_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='')
|
||||
{
|
||||
print load_fiche_titre($titre, $mesg, $picto, $pictoisfullpath, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Print a title with navigation controls for pagination
|
||||
* \param titre Title to show (required)
|
||||
|
||||
@ -47,7 +47,7 @@ class ProductDefault extends Product
|
||||
$this->module = "produit";
|
||||
$this->canvas = "default";
|
||||
$this->name = "default";
|
||||
$this->description = "Canvas des produits (défaut)";
|
||||
$this->definition = "Canvas des produits (défaut)";
|
||||
$this->fieldListName = "product_default";
|
||||
|
||||
$this->next_prev_filter = "canvas='default'";
|
||||
@ -77,7 +77,9 @@ class ProductDefault extends Product
|
||||
*/
|
||||
function assign_values($action='')
|
||||
{
|
||||
global $conf,$langs,$html;
|
||||
global $conf,$langs;
|
||||
global $html;
|
||||
global $formproduct;
|
||||
|
||||
// Ref
|
||||
$this->tpl['ref'] = $this->ref;
|
||||
@ -95,7 +97,7 @@ class ProductDefault extends Product
|
||||
$this->tpl['note'] = nl2br($this->note);
|
||||
|
||||
// Hidden
|
||||
if ($user->rights->produit->hidden)
|
||||
if ($this->user->rights->produit->hidden)
|
||||
{
|
||||
$this->tpl['hidden'] = yn($this->hidden);
|
||||
}
|
||||
@ -112,6 +114,17 @@ class ProductDefault extends Product
|
||||
// Title
|
||||
$this->tpl['title'] = load_fiche_titre($langs->trans("NewProduct"));
|
||||
|
||||
// Price
|
||||
$this->tpl['price'] = $this->price;
|
||||
$this->tpl['price_min'] = $this->price_min;
|
||||
$this->tpl['price_base_type'] = $html->load_PriceBaseType($this->price_base_type, "price_base_type");
|
||||
|
||||
// VAT
|
||||
$this->tpl['tva_tx'] = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
// Status
|
||||
$statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
|
||||
$this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status);
|
||||
@ -119,24 +132,51 @@ class ProductDefault extends Product
|
||||
// Finished
|
||||
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||
$this->tpl['finished'] = $html->selectarray('finished',$statutarray,$this->finished);
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
|
||||
// Weight
|
||||
$this->tpl['weight'] = $this->weight;
|
||||
$this->tpl['weight_units'] = $formproduct->load_measuring_units("weight_units","weight",$this->weight_units);
|
||||
|
||||
// Length
|
||||
$this->tpl['length'] = $this->length;
|
||||
$this->tpl['length_units'] = $formproduct->load_measuring_units("length_units","size",$this->length_units);
|
||||
|
||||
// Surface
|
||||
$this->tpl['surface'] = $this->surface;
|
||||
$this->tpl['surface_units'] = $formproduct->load_measuring_units("surface_units","surface",$this->surface_units);
|
||||
|
||||
// Volume
|
||||
$this->tpl['volume'] = $this->volume;
|
||||
$this->tpl['volume_units'] = $formproduct->load_measuring_units("volume_units","volume",$this->volume_units);
|
||||
|
||||
// Hidden
|
||||
if ($this->user->rights->produit->hidden)
|
||||
{
|
||||
$this->tpl['hidden'] = $html->selectyesno('hidden',$this->hidden);
|
||||
}
|
||||
|
||||
// TODO creer fonction
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
$doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false);
|
||||
$this->tpl['doleditor'] = $doleditor;
|
||||
|
||||
$doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
|
||||
$this->tpl['doleditor_description'] = $doleditor;
|
||||
|
||||
$doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
|
||||
$this->tpl['doleditor_note'] = $doleditor;
|
||||
}
|
||||
else
|
||||
{
|
||||
$textarea = '<textarea name="desc" rows="4" cols="90">';
|
||||
$textarea.= $product->description;
|
||||
$textarea.= $this->description;
|
||||
$textarea.= '</textarea>';
|
||||
$this->tpl['textarea_description'] = $textarea;
|
||||
|
||||
$this->tpl['textarea'] = $textarea;
|
||||
$textarea = '<textarea name="note" rows="8" cols="70">';
|
||||
$textarea.= $this->note;
|
||||
$textarea.= '</textarea>';
|
||||
$this->tpl['textarea_note'] = $textarea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,10 +55,10 @@
|
||||
<?php } ?>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("Description"); ?></td><td>
|
||||
<?php if (! $product->tpl['textarea']) {
|
||||
$product->tpl['doleditor']->Create();
|
||||
<?php if (! $product->tpl['textarea_description']) {
|
||||
$product->tpl['doleditor_description']->Create();
|
||||
}else{
|
||||
echo $product->tpl['textarea'];
|
||||
echo $product->tpl['textarea_description'];
|
||||
}?>
|
||||
</td></tr>
|
||||
|
||||
@ -67,85 +67,60 @@ echo $product->tpl['textarea'];
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Weight"); ?></td><td>
|
||||
<input name="weight" size="4" value="<?php echo $_POST["weight"]; ?>">
|
||||
print $formproduct->select_measuring_units("weight_units","weight");
|
||||
<input name="weight" size="4" value="<?php echo $product->tpl['weight']; ?>">
|
||||
<?php echo $product->tpl['weight_units']; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Length"); ?></td><td>
|
||||
<input name="size" size="4" value="<?php echo $_POST["size"]; ?>">
|
||||
print $formproduct->select_measuring_units("size_units","size");
|
||||
<input name="size" size="4" value="<?php echo $product->tpl['length']; ?>">
|
||||
<?php echo $product->tpl['length_units']; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Surface"); ?></td><td>
|
||||
<input name="surface" size="4" value="<?php echo $_POST["surface"]; ?>">
|
||||
print $formproduct->select_measuring_units("surface_units","surface");
|
||||
<input name="surface" size="4" value="<?php echo $product->tpl['surface']; ?>">
|
||||
<?php echo $product->tpl['surface_units']; ?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td><?php echo $langs->trans("Volume"); ?></td><td>
|
||||
<input name="volume" size="4" value="<?php echo $_POST["volume"]; ?>">
|
||||
print $formproduct->select_measuring_units("volume_units","volume");
|
||||
<input name="volume" size="4" value="<?php echo $product->tpl['volume']; ?>">
|
||||
<?php echo $product->tpl['volume_units']; ?>
|
||||
</td></tr>
|
||||
|
||||
// Hidden
|
||||
if (($_GET["type"] != 1 && $user->rights->produit->hidden)
|
||||
|| ($_GET["type"] == 1 && $user->rights->service->hidden))
|
||||
{
|
||||
<tr><td><?php echo $langs->trans("Hidden"); ?></td><td>
|
||||
print $html->selectyesno('hidden',$product->hidden);
|
||||
</td></tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
print yn("No");
|
||||
}
|
||||
<tr><td><?php echo $langs->trans("Hidden"); ?></td>
|
||||
<td><?php echo $product->tpl['hidden']; ?></td></tr>
|
||||
|
||||
<tr><td valign="top"><?php echo $langs->trans("NoteNotVisibleOnBill"); ?></td><td>
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
$doleditor=new DolEditor('note',$_POST["note"],180,'dolibarr_notes','',false);
|
||||
$doleditor->Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<textarea name="note" rows="8" cols="70">';
|
||||
print $_POST["note"];
|
||||
print '</textarea>';
|
||||
}
|
||||
<?php if (! $product->tpl['textarea_note']) {
|
||||
$product->tpl['doleditor_note']->Create();
|
||||
}else{
|
||||
echo $product->tpl['textarea_note'];
|
||||
}?>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
if ($conf->global->PRODUIT_MULTIPRICES)
|
||||
{
|
||||
// We do no show price array on create when multiprices enabled.
|
||||
// We must set them on prices tab.
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
<?php if (! $conf->global->PRODUIT_MULTIPRICES) { ?>
|
||||
|
||||
// PRIX
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td>';
|
||||
print '<td><input name="price" size="10" value="'.$product->price.'">';
|
||||
print $html->select_PriceBaseType($product->price_base_type, "price_base_type");
|
||||
print '</td></tr>';
|
||||
<table class="border" width="100%">
|
||||
|
||||
// MIN PRICE
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td>';
|
||||
print '<td><input name="price_min" size="10" value="'.$product->price_min.'">';
|
||||
print '</td></tr>';
|
||||
<tr><td><?php echo $langs->trans("SellingPrice"); ?></td>
|
||||
<td><input name="price" size="10" value="<?php echo $product->tpl['price']; ?>">
|
||||
<?php echo $product->tpl['price_base_type']; ?>
|
||||
</td></tr>
|
||||
|
||||
// VAT
|
||||
print '<tr><td width="20%">'.$langs->trans("VATRate").'</td><td>';
|
||||
print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
||||
print '</td></tr>';
|
||||
<tr><td><?php echo $langs->trans("MinPrice"); ?></td>
|
||||
<td><input name="price_min" size="10" value="<?php echo $product->tpl['price_min']; ?>">
|
||||
</td></tr>
|
||||
|
||||
print '</table>';
|
||||
<tr><td width="20%"><?php echo $langs->trans("VATRate"); ?></td><td>
|
||||
<?php echo $product->tpl['tva_tx']; ?>
|
||||
</td></tr>
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<?php } ?>
|
||||
|
||||
<center><input type="submit" class="button" value="<?php echo $langs->trans("Create"); ?>"></center>
|
||||
|
||||
|
||||
@ -117,8 +117,7 @@ class FormProduct
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Selection des unites de mesure
|
||||
* \param name Nom champ html
|
||||
@ -127,9 +126,23 @@ class FormProduct
|
||||
* \remarks pour l'instant on ne definit pas les unites dans la base
|
||||
*/
|
||||
function select_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0)
|
||||
{
|
||||
print $this->load_measuring_units($name, $measuring_style, $default, $adddefault);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Selection des unites de mesure
|
||||
* \param name Nom champ html
|
||||
* \param measuring_style Le style de mesure : weight, volume,...
|
||||
* \param default Forcage de l'unite
|
||||
* \remarks pour l'instant on ne definit pas les unites dans la base
|
||||
*/
|
||||
function load_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0)
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
$langs->load("other");
|
||||
|
||||
$return='';
|
||||
|
||||
if ($measuring_style == 'weight')
|
||||
{
|
||||
@ -160,19 +173,21 @@ class FormProduct
|
||||
$measuring_units[-9] = $langs->trans("VolumeUnitmm3");
|
||||
}
|
||||
|
||||
print '<select class="flat" name="'.$name.'">';
|
||||
if ($adddefault) print '<option value="0">'.$langs->trans("Default").'</option>';
|
||||
$return.= '<select class="flat" name="'.$name.'">';
|
||||
if ($adddefault) $return.= '<option value="0">'.$langs->trans("Default").'</option>';
|
||||
|
||||
foreach ($measuring_units as $key => $value)
|
||||
{
|
||||
print '<option value="'.$key.'"';
|
||||
$return.= '<option value="'.$key.'"';
|
||||
if ($key == $default)
|
||||
{
|
||||
print ' selected="true"';
|
||||
$return.= ' selected="true"';
|
||||
}
|
||||
print '>'.$value.'</option>';
|
||||
$return.= '>'.$value.'</option>';
|
||||
}
|
||||
print '</select>';
|
||||
$return.= '</select>';
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user