Merge branch '3.6' of git@github.com:Dolibarr/dolibarr.git into 3.6

This commit is contained in:
Florian HENRY 2014-09-03 11:44:37 +02:00
commit b04eae95e5
17 changed files with 380 additions and 352 deletions

View File

@ -140,9 +140,9 @@ Fix: Link product, In list view and label product.
Fix: visible task into area "time" for "My task" must limit task to tasks i am assigned to.
Fix: When disabled, all fields to add time into task line must be disabled.
Fix: Missing include files.lib.php in some pages that use dol_delete_recursive
Fix: Missing include files.lib.php in some pages ti use dol_delete_recursive.
Fix: [ bug #1558 ] Product/service edit page title shows new Ref instead of old ref.
Fix: [ bug #1553 ] Saving User displays setup removes menu.
Fix: [ bug #1544 ] Can remove date from invoice
***** ChangeLog for 3.5.4 compared to 3.5.3 *****
Fix: Hide title of event when agenda module disabled.

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Jean Heimburger <jean@tiaris.info>
@ -9,7 +9,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
@ -291,6 +291,13 @@ class Commande extends CommonOrder
}
}
// Set new ref and current status
if (! $error)
{
$this->ref = $num;
$this->statut = 1;
}
if (! $error)
{
// Appel des triggers
@ -301,13 +308,6 @@ class Commande extends CommonOrder
// Fin appel triggers
}
// Set new ref and current status
if (! $error)
{
$this->ref = $num;
$this->statut = 1;
}
if (! $error)
{
$this->db->commit();

View File

@ -248,18 +248,23 @@ else if ($action == 'setmode' && $user->rights->facture->creer) {
dol_print_error($db, $object->error);
}
else if ($action == 'setinvoicedate' && $user->rights->facture->creer) {
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
{
$object->fetch($id);
$old_date_lim_reglement = $object->date_lim_reglement;
$object->date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']);
$date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']);
if (empty($date))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate');
exit;
}
$object->date=$date;
$new_date_lim_reglement = $object->calculate_date_lim_reglement();
if ($new_date_lim_reglement > $old_date_lim_reglement)
$object->date_lim_reglement = $new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date)
$object->date_lim_reglement = $object->date;
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
$result = $object->update($user);
if ($result < 0)
dol_print_error($db, $object->error);
if ($result < 0) dol_print_error($db, $object->error);
}
else if ($action == 'setconditions' && $user->rights->facture->creer) {
@ -267,18 +272,14 @@ else if ($action == 'setconditions' && $user->rights->facture->creer) {
$object->cond_reglement_code = 0; // To clean property
$object->cond_reglement_id = 0; // To clean property
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0)
dol_print_error($db, $object->error);
if ($result < 0) dol_print_error($db, $object->error);
$old_date_lim_reglement = $object->date_lim_reglement;
$new_date_lim_reglement = $object->calculate_date_lim_reglement();
if ($new_date_lim_reglement > $old_date_lim_reglement)
$object->date_lim_reglement = $new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date)
$object->date_lim_reglement = $object->date;
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement;
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
$result = $object->update($user);
if ($result < 0)
dol_print_error($db, $object->error);
if ($result < 0) dol_print_error($db, $object->error);
}
else if ($action == 'setpaymentterm' && $user->rights->facture->creer) {
@ -1143,12 +1144,12 @@ else if ($action == 'addline' && $user->rights->facture->creer)
// We define price for product
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level))
{
$pu_ht = $prod->multiprices [$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc [$object->client->price_level];
$price_min = $prod->multiprices_min [$object->client->price_level];
$price_base_type = $prod->multiprices_base_type [$object->client->price_level];
$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
$pu_ht = $prod->multiprices[$object->client->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->client->price_level];
$price_min = $prod->multiprices_min[$object->client->price_level];
$price_base_type = $prod->multiprices_base_type[$object->client->price_level];
//$tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
//$tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
}
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{

View File

@ -1320,6 +1320,16 @@ if ($action == 'create')
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
print '</td></tr>';
// Project
if (! empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
$formproject->select_projects($soc->id, $projectid, 'projectid');
print '</td></tr>';
}
// Public note
print '<tr><td>'.$langs->trans('NotePublic').'</td>';
print '<td>';

View File

@ -23,9 +23,11 @@ ShowResourcePlanning=Show resource planning
NoResourceInDatabase=No resource in database
GotoDate=Go to date
ResourceElementPage=Element resources
ResourceCreatedWithSuccess=Resource successfully created
RessourceLineSuccessfullyDeleted=Resource line successfully deleted
RessourceLineSuccessfullyUpdated=Resource line successfully updated
ResourceLinkedWithSuccess=Resource linked with success
TitleResourceCard=Resource card
ConfirmDeleteResource=Confirm to delete this resource

View File

@ -2,7 +2,7 @@
MenuResourceIndex=Ressources
MenuResourceAdd=Nouvelle ressource
MenuResourcePlanning=Planning des Ressources
DeleteResource=Effacer resource
DeleteResource=Effacer ressource
ConfirmDeleteResourceElement=Confirmer la suppression de la ressource pour cet élément
NoResourceInDatabase=Aucune ressource en base de données.
NoResourceLinked=Aucune ressource liée
@ -17,17 +17,19 @@ ResourceFormLabel_description=Description de la ressource
ResourcesLinkedToElement=Ressources liées à l'élément
RessourceLineSuccessfullyUpdated=Ressource mise à jour
RessourceLineSuccessfullyDeleted=Resource supprimée
RessourceLineSuccessfullyDeleted=Ressource supprimée
ShowResourcePlanning=Montrer le planning des ressources
PlanningOfAffectedResources=Planning des ressources affectées aux évènements
GotoDate=Afficher la date
ResourceElementPage=Ressources de l'élément
ResourceCreatedWithSuccess=Ressource créee avec succès
RessourceLineSuccessfullyDeleted=Ressource supprimée avec succès
RessourceLineSuccessfullyUpdated=Ressource mise à jour
ResourceLinkedWithSuccess=Ressource liée avec succès
TitleResourceCard=Fiche resource
TitleResourceCard=Fiche ressource
ConfirmDeleteResource=Confirmer la suppression de cette ressource?
RessourceSuccessfullyDeleted=Ressource effacée avec succès
DictionaryResourceType=Type de ressources

View File

@ -466,7 +466,7 @@ if (empty($reshook))
if ($result > 0)
{
header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref));
header('Location: '.DOL_URL_ROOT.'/product/liste.php?type='.$object->type.'&delprod='.urlencode($object->ref));
exit;
}
else

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db);
}
@ -58,18 +58,18 @@ $object = new Product($db);
if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$result = $object->fetch($id);
// MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
if (! empty($conf->global->PRODUIT_MULTIPRICES))
{
$newprice = '';
$newprice_min = '';
$newpricebase = '';
$newvat = '';
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
if (isset($_POST ["price_" . $i]))
if (isset($_POST ["price_" . $i]))
{
$level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU');
@ -92,7 +92,7 @@ if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit-
$newpsq = GETPOST('psqflag');
$newpsq = empty($newpsq) ? 0 : $newpsq;
}
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) {
$action = '';
$mesg = '<div class="ok">' . $langs->trans("RecordSaved") . '</div>';
@ -115,7 +115,7 @@ $error = 0;
if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity
$result = $object->fetch($id);
$level = GETPOST('level');
$object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
}
@ -125,7 +125,7 @@ if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité
if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par quantité
$result = $object->fetch($id);
// Récupération des variables
$rowid = GETPOST('rowid');
$priceid = GETPOST('priceid');
@ -148,10 +148,10 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
if ($object->price_base_type == 'TTC') {
$price = price2num($newprice) / (1 + ($object->tva_tx / 100));
}
$price = price2num($newprice, 'MU');
$unitPrice = price2num($price / $quantity, 'MU');
// Ajout / mise à jour
if ($rowid > 0) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "product_price_by_qty SET";
@ -161,12 +161,12 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
$sql .= " remise_percent=" . $remise_percent . ",";
$sql .= " remise=" . $remise;
$sql .= " WHERE rowid = " . GETPOST('rowid');
$result = $db->query($sql);
} else {
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
$sql .= $priceid . ',' . $price . ',' . $unitPrice . ',' . $quantity . ',' . $remise_percent . ',' . $remise . ')';
$result = $db->query($sql);
}
}
@ -174,19 +174,19 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
if ($action == 'delete_price_by_qty') {
$rowid = GETPOST('rowid');
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE rowid = " . GETPOST('rowid');
$result = $db->query($sql);
}
if ($action == 'delete_all_price_by_qty') {
$priceid = GETPOST('priceid');
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
$sql .= " WHERE fk_product_price = " . $priceid;
$result = $db->query($sql);
}
@ -196,11 +196,11 @@ if ($action == 'delete_all_price_by_qty') {
* ****************************************************
*/
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice');
$result = $object->fetch($id);
// add price by customer
$prodcustprice->fk_soc = GETPOST('socid', 'int');
$prodcustprice->fk_product = $object->id;
@ -209,15 +209,15 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
$action = '';
}
@ -225,7 +225,7 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer ||
// Delete price by customer
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'mesgs');
} else {
@ -235,26 +235,26 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer ||
}
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice');
$prodcustprice->fetch(GETPOST('lineid', 'int'));
// update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
$action = '';
}
@ -304,22 +304,22 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch($socid);
print '<tr><td>' . $langs->trans("SellingPrice") . '</td>';
if ($object->multiprices_base_type ["$soc->price_level"] == 'TTC') {
print '<td>' . price($object->multiprices_ttc ["$soc->price_level"]);
} else {
print '<td>' . price($object->multiprices ["$soc->price_level"]);
}
if ($object->multiprices_base_type ["$soc->price_level"]) {
print ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
} else {
print ' ' . $langs->trans($object->price_base_type);
}
print '</td></tr>';
// Prix mini
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
if ($object->multiprices_base_type ["$soc->price_level"] == 'TTC') {
@ -328,41 +328,41 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->multiprices_min ["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
}
print '</td></tr>';
// TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->multiprices_tva_tx ["$soc->price_level"], true) . '</td></tr>';
}
}
else
{
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
// TVA
if ($i == 1) // We show only price for level 1
{
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->multiprices_tva_tx [1], true) . '</td></tr>';
}
print '<tr>';
// Label of price
print '<td>' . $langs->trans("SellingPrice") . ' ' . $i;
$keyforlabel='PRODUIT_MULTIPRICES_LABEL'.$i;
if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel);
print '</td>';
if ($object->multiprices_base_type ["$i"] == 'TTC') {
print '<td>' . price($object->multiprices_ttc ["$i"]);
} else {
print '<td>' . price($object->multiprices ["$i"]);
}
if ($object->multiprices_base_type ["$i"]) {
print ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
} else {
print ' ' . $langs->trans($object->price_base_type);
}
print '</td></tr>';
// Prix mini
print '<tr><td>' . $langs->trans("MinPrice") . ' ' . $i . '</td><td>';
if ($object->multiprices_base_type ["$i"] == 'TTC') {
@ -371,15 +371,15 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->multiprices_min ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
}
print '</td></tr>';
// Price by quantity
if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
print '<tr><td>' . $langs->trans("PriceByQuantity") . ' ' . $i;
print '</td><td>';
if ($object->prices_by_qty [$i] == 1) {
print '<table width="50%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("PriceByQuantityRange") . ' ' . $i . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
@ -434,7 +434,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '</tr>';
print '</form>';
}
print '</table>';
} else {
print $langs->trans("No");
@ -447,7 +447,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
} else {
// TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>';
// Price
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
if ($object->price_base_type == 'TTC') {
@ -456,7 +456,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->price) . ' ' . $langs->trans($object->price_base_type);
}
print '</td></tr>';
// Price minimum
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
if ($object->price_base_type == 'TTC') {
@ -465,7 +465,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
}
print '</td></tr>';
// Price by quantity
if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
print '<tr><td>' . $langs->trans("PriceByQuantity");
@ -473,7 +473,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '&nbsp;<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=activate_price_by_qty&level=1">' . $langs->trans("Activate");
}
print '</td><td>';
if ($object->prices_by_qty [0] == 1) {
print '<table width="50%" class="noborder">';
print '<tr class="liste_titre">';
@ -530,7 +530,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '</tr>';
print '</form>';
}
print '</table>';
} else {
print $langs->trans("No");
@ -560,11 +560,11 @@ if (! empty($mesg)) {
if (! $action || $action == 'delete') {
print "\n" . '<div class="tabsAction">' . "\n";
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=edit_price&amp;id=' . $object->id . '">' . $langs->trans("UpdatePrice") . '</a></div>';
}
print "\n</div>\n";
}
@ -573,19 +573,19 @@ if (! $action || $action == 'delete') {
*/
if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
print_fiche_titre($langs->trans("NewPrice"), '', '');
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="border" width="100%">';
// VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr);
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print $langs->trans('PriceBase');
@ -594,7 +594,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
// Price
print '<tr><td width="20%">';
$text = $langs->trans('SellingPrice');
@ -606,7 +606,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<input name="price" size="10" value="' . price($object->price) . '">';
}
print '</td></tr>';
// Price minimum
print '<tr><td>';
$text = $langs->trans('MinPrice');
@ -617,12 +617,12 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
}
print '</td></tr>';
print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>';
} else {
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
@ -631,7 +631,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<input type="hidden" name="action" value="update_price">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="border" width="100%">';
// VAT
if ($i == 1) {
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
@ -640,7 +640,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
} else { // We always use the vat rate of price level 1 (A vat rate does not depends on customer)
print '<input type="hidden" name="tva_tx_' . $i . '" value="' . $object->multiprices_tva_tx [1] . '">';
}
// Selling price
print '<tr><td width="20%">';
$text = $langs->trans('SellingPrice') . ' ' . $i;
@ -653,7 +653,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
}
print $form->select_PriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i);
print '</td></tr>';
// Min price
print '<tr><td>';
$text = $langs->trans('MinPrice') . ' ' . $i;
@ -664,7 +664,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min ["$i"]) . '">';
}
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></td></tr>';
print '</table>';
@ -691,33 +691,33 @@ dol_syslog("sql=" . $sql);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
if (! $num) {
$db->free($result);
// Il doit au moins y avoir la ligne de prix initial.
// On l'ajoute donc pour remettre a niveau (pb vieilles versions)
$object->updatePrice($object->price, $object->price_base_type, $user, $newprice_min);
$result = $db->query($sql);
$num = $db->num_rows($result);
}
if ($num > 0) {
print '<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '<td align="center">' . $langs->trans("MultiPriceLevelsName") . '</td>';
}
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
print '<td align="center">' . $langs->trans("Type") . '</td>';
}
print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans("VAT") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
@ -728,7 +728,7 @@ if ($result) {
if ($user->rights->produit->supprimer)
print '<td align="right">&nbsp;</td>';
print '</tr>';
$var = True;
$i = 0;
while ($i < $num) {
@ -737,7 +737,7 @@ if ($result) {
print "<tr $bc[$var]>";
// Date
print "<td>" . dol_print_date($db->jdate($objp->dp), "dayhour") . "</td>";
// Price level
if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
print '<td align="center">' . $objp->price_level . "</td>";
@ -747,17 +747,17 @@ if ($result) {
$type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard';
print '<td align="center">' . $langs->trans($type) . "</td>";
}
print '<td align="center">' . $langs->trans($objp->price_base_type) . "</td>";
print '<td align="right">' . vatrate($objp->tva_tx, true, $objp->recuperableonly) . "</td>";
print '<td align="right">' . price($objp->price) . "</td>";
print '<td align="right">' . price($objp->price_ttc) . "</td>";
print '<td align="right">' . price($objp->price_min) . '</td>';
print '<td align="right">' . price($objp->price_min_ttc) . '</td>';
// User
print '<td align="right"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $objp->user_id . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . '</a></td>';
// Action
if ($user->rights->produit->supprimer) {
print '<td align="right">';
@ -769,7 +769,7 @@ if ($result) {
print '&nbsp;'; // Can not delete last price (it's current price)
print '</td>';
}
print "</tr>\n";
$i ++;
}
@ -782,9 +782,9 @@ if ($result) {
}
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$prodcustprice = new Productcustomerprice($db);
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -798,21 +798,21 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$sortorder = "ASC";
if (! $sortfield)
$sortfield = "soc.nom";
// Build filter to diplay only concerned lines
$filter = array('t.fk_product' => $object->id);
$search_soc = GETPOST('search_soc');
if (! empty($search_soc)) {
$filter ['soc.nom'] = $search_soc;
}
if ($action == 'add_customer_price') {
// Create mode
print_fiche_titre($langs->trans('PriceByCustomer'));
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="add_customer_price_confirm">';
@ -824,12 +824,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_company('', 'socid', 's.rowid NOT IN (SELECT fk_soc FROM ' . MAIN_DB_PREFIX . 'product_customer_price WHERE fk_product='.$object->id.')', 1);
print '</td>';
print '</tr>';
// VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr);
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print $langs->trans('PriceBase');
@ -838,7 +838,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
// Price
print '<tr><td width="20%">';
$text = $langs->trans('SellingPrice');
@ -850,7 +850,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input name="price" size="10" value="' . price($object->price) . '">';
}
print '</td></tr>';
// Price minimum
print '<tr><td>';
$text = $langs->trans('MinPrice');
@ -861,7 +861,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
}
print '</td></tr>';
// Update all child soc
print '<tr><td width="15%">';
print $langs->trans('ForceUpdateChildPriceSoc');
@ -870,24 +870,24 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input type="checkbox" name="updatechildprice" value="1">';
print '</td>';
print '</tr>';
print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>';
} elseif ($action == 'edit_customer_price') {
// Edit mode
print_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_customer_price_confirm">';
@ -899,12 +899,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$staticsoc->fetch($prodcustprice->fk_soc);
print "<td>" . $staticsoc->getNomUrl(1) . "</td>";
print '</tr>';
// VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly);
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print $langs->trans('PriceBase');
@ -913,7 +913,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
// Price
print '<tr><td width="20%">';
$text = $langs->trans('SellingPrice');
@ -925,18 +925,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
}
print '</td></tr>';
// Price minimum
print '<tr><td>';
$text = $langs->trans('MinPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>';
if ($prodcustprice->price_base_type == 'TTC') {
print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
} else {
print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
}
print '</td></tr>';
// Update all child soc
print '<tr><td width="15%">';
print $langs->trans('ForceUpdateChildPriceSoc');
@ -945,39 +946,39 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input type="checkbox" name="updatechildprice" value="1">';
print '</td>';
print '</tr>';
print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>';
} elseif ($action == 'showlog_customer_price') {
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int'));
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
}
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
$option = '&socid=' . GETPOST('socid', 'int') . '&id=' . $object->id;
print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
if (count($prodcustprice->lines) > 0) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("ThirdParty") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
@ -990,26 +991,26 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var = True;
foreach ($prodcustprice->lines as $line) {
print "<tr $bc[$var]>";
// Date
$staticsoc = new Societe($db);
$staticsoc->fetch($line->fk_soc);
print "<td>" . $staticsoc->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
@ -1021,36 +1022,36 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} else {
print $langs->trans('None');
}
print "\n" . '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
print "\n</div><br>\n";
} else {
// View mode
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
$option = '&search_soc=' . $search_soc . '&id=' . $object->id;
print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
if (count($prodcustprice->lines) > 0) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("ThirdParty") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
@ -1063,7 +1064,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
print '<tr class="liste_titre">';
print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
print '<td colspan="8">&nbsp;</td>';
@ -1072,33 +1073,33 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>';
print '</tr>';
$var = True;
foreach ($prodcustprice->lines as $line) {
print "<tr $bc[$var]>";
// Date
$staticsoc = new Societe($db);
$staticsoc->fetch($line->fk_soc);
print "<td>" . $staticsoc->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
print '<td align="right">';
print $userstatic->getLoginUrl(1);
print '</td>';
// Todo Edit or delete button
// Action
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
@ -1114,24 +1115,24 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</a>';
print '</td>';
}
print "</tr>\n";
}
print "</table>";
print "</form>";
} else {
print $langs->trans('None');
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n" . '<div class="tabsAction">' . "\n";
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;id=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
}

View File

@ -82,87 +82,5 @@ class ActionsResource
}
}
}
if (in_array('element_resource',explode(':',$parameters['context'])))
{
$element_id = GETPOST('element_id','int');
$element = GETPOST('element','alpha');
$resource_type = GETPOST('resource_type');
$fk_resource = GETPOST('fk_resource');
$busy = GETPOST('busy','int');
$mandatory = GETPOST('mandatory','int');
if($action == 'add_element_resource' && !GETPOST('cancel'))
{
$objstat = fetchObjectByElement($element_id,$element);
$res = $objstat->add_element_resource($fk_resource,$resource_type,$busy,$mandatory);
if($res > 0)
{
setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
exit;
}
else
{
setEventMessage($langs->trans('ErrorWhenLinkingResource'),'errors');
header("Location: ".$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_type.'&element='.$element.'&element_id='.$element_id);
exit;
}
}
// Delete a resource linked to an element
if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && GETPOST('confirm') == 'yes')
{
$res = $object->fetch(GETPOST('id'));
if($res)
{
$result = $object->delete_resource(GETPOST('lineid'),GETPOST('element'));
if ($result >= 0)
{
setEventMessage($langs->trans('RessourceLineSuccessfullyDeleted'));
Header("Location: ".$_SERVER['PHP_SELF']."?element=".GETPOST('element')."&element_id=".GETPOST('element_id'));
exit;
}
else {
setEventMessage($object->error,'errors');
}
}
else
{
setEventMessage($object->error,'errors');
}
}
// Update ressource
if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel') )
{
$res = $object->fetch_element_resource(GETPOST('lineid'));
if($res)
{
$object->busy = GETPOST('busy');
$object->mandatory = GETPOST('mandatory');
$result = $object->update_element_resource($user);
if ($result >= 0)
{
setEventMessage($langs->trans('RessourceLineSuccessfullyUpdated'));
Header("Location: ".$_SERVER['PHP_SELF']."?element=".GETPOST('element')."&element_id=".GETPOST('element_id'));
exit;
}
else {
setEventMessage($object->error,'errors');
}
}
}
}
}*/
}

View File

@ -779,7 +779,7 @@ class Resource extends CommonObject
// Links beetween objects are stored in this table
$sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory';
$sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources';
$sql.= " WHERE element_id='".$element_id."' AND resource_type='".$this->element."'";
$sql.= " WHERE element_id='".$element_id."' AND element_type='".$element."'";
if($resource_type)
$sql.=" AND resource_type LIKE '%".$resource_type."%'";
$sql .= ' ORDER BY resource_type';

View File

@ -57,13 +57,90 @@ if( ! $user->rights->resource->read)
$object=new Resource($db);
$hookmanager->initHooks(array('element_resource'));
$object->available_resources = array('resource');
$parameters=array('resource_id'=>$available_resources);
// Get parameters
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha');
$lineid = GETPOST('lineid','int');
$element = GETPOST('element','alpha');
$element_id = GETPOST('element_id','int');
$resource_id = GETPOST('fk_resource','int');
$resource_type = GETPOST('resource_type','alpha');
$busy = GETPOST('busy','int');
$mandatory = GETPOST('mandatory','int');
if($action == 'add_element_resource' && !GETPOST('cancel'))
{
$objstat = fetchObjectByElement($element_id,$element);
$res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory);
if($res > 0)
{
setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
exit;
}
else
{
setEventMessage($langs->trans('ErrorWhenLinkingResource'),'errors');
header("Location: ".$_SERVER['PHP_SELF'].'?mode=add&resource_type='.$resource_type.'&element='.$element.'&element_id='.$element_id);
exit;
}
}
// Update ressource
if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel') )
{
$res = $object->fetch_element_resource($lineid);
if($res)
{
$object->busy = $busy;
$object->mandatory = $mandatory;
$result = $object->update_element_resource($user);
if ($result >= 0)
{
setEventMessage($langs->trans('RessourceLineSuccessfullyUpdated'));
Header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id);
exit;
}
else {
setEventMessage($object->error,'errors');
}
}
}
// Delete a resource linked to an element
if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->delete && GETPOST('confirm') == 'yes')
{
$res = $object->fetch(GETPOST('id'));
if($res)
{
$result = $object->delete_resource($lineid,$element);
if ($result >= 0)
{
setEventMessage($langs->trans('RessourceLineSuccessfullyDeleted'));
Header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id);
exit;
}
else {
setEventMessage($object->error,'errors');
}
}
else
{
setEventMessage($object->error,'errors');
}
}
$parameters=array('resource_id'=>resource_id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$parameters=array('resource_id'=>$resource_id);
$reshook=$hookmanager->executeHooks('getElementResources',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db);
}
@ -54,9 +54,9 @@ $result = restrictedArea($user, 'societe', $socid, '&societe');
* ****************************************************
*/
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice');
// add price by customer
$prodcustprice->fk_soc = $socid;
$prodcustprice->fk_product = GETPOST('prodid', 'int');
@ -65,15 +65,15 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
$action = '';
}
@ -81,7 +81,7 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $use
// Delete price by customer
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'mesgs');
} else {
@ -91,25 +91,25 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $use
}
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$prodcustprice->fetch(GETPOST('lineid', 'int'));
$update_child_soc = GETPOST('updatechildprice');
// update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
}
$action = '';
}
@ -199,9 +199,9 @@ print '</table>';
print '</div>';
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$prodcustprice = new Productcustomerprice($db);
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOST("page", 'int');
@ -215,23 +215,23 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$sortorder = "ASC";
if (! $sortfield)
$sortfield = "soc.nom";
// Build filter to diplay only concerned lines
$filter = array (
't.fk_soc' => $soc->id
't.fk_soc' => $soc->id
);
$search_soc = GETPOST('search_soc');
if (! empty($search_soc)) {
$filter ['soc.nom'] = $search_soc;
}
if ($action == 'add_customer_price') {
// Create mode
print_fiche_titre($langs->trans('PriceByCustomer'));
print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="add_customer_price_confirm">';
@ -243,12 +243,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_produits('', 'prodid', '', 0);
print '</td>';
print '</tr>';
// VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr);
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print $langs->trans('PriceBase');
@ -257,7 +257,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_PriceBaseType($object->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
// Price
print '<tr><td width="20%">';
$text = $langs->trans('SellingPrice');
@ -269,7 +269,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input name="price" size="10" value="' . price($object->price) . '">';
}
print '</td></tr>';
// Price minimum
print '<tr><td>';
$text = $langs->trans('MinPrice');
@ -280,7 +280,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
}
print '</td></tr>';
// Update all child soc
print '<tr><td width="15%">';
print $langs->trans('ForceUpdateChildPriceSoc');
@ -289,24 +289,24 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input type="checkbox" name="updatechildprice" value="1"/>';
print '</td>';
print '</tr>';
print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>';
} elseif ($action == 'edit_customer_price') {
// Edit mode
print_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_customer_price_confirm">';
@ -318,12 +318,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$staticprod->fetch($prodcustprice->fk_product);
print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print '</tr>';
// VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print $langs->trans('PriceBase');
@ -332,7 +332,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type");
print '</td>';
print '</tr>';
// Price
print '<tr><td width="20%">';
$text = $langs->trans('SellingPrice');
@ -344,18 +344,19 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
}
print '</td></tr>';
// Price minimum
print '<tr><td>';
$text = $langs->trans('MinPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>';
if ($prodcustprice->price_base_type == 'TTC') {
print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
} else {
print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
}
print '</td></tr>';
// Update all child soc
print '<tr><td width="15%">';
print $langs->trans('ForceUpdateChildPriceSoc');
@ -364,41 +365,41 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input type="checkbox" name="updatechildprice" value="1">';
print '</td>';
print '</tr>';
print '</table>';
print '<center><br><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>';
} elseif ($action == 'showlog_customer_price') {
$filter = array (
't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
);
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
}
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
$option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
if (count($prodcustprice->lines) > 0) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
@ -411,25 +412,25 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var = True;
foreach ( $prodcustprice->lines as $line ) {
print "<tr $bc[$var]>";
$staticprod = new Product($db);
$staticprod->fetch($line->fk_product);
print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
@ -441,36 +442,36 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} else {
print $langs->trans('None');
}
print "\n" . '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '">' . $langs->trans("Ok") . '</a></div>';
print "\n</div><br>\n";
} else {
// View mode
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
}
$option = '&search_soc=' . $search_soc . '&id=' . $object->id;
print_barre_liste($langs->trans('PriceByCustomer'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
if (count($prodcustprice->lines) > 0) {
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
@ -483,7 +484,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
print '<tr class="liste_titre">';
print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
print '<td colspan="8">&nbsp;</td>';
@ -492,33 +493,33 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '</td>';
print '</tr>';
$var = True;
foreach ( $prodcustprice->lines as $line ) {
print "<tr $bc[$var]>";
$staticprod = new Product($db);
$staticprod->fetch($line->fk_product);
print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
print '<td align="right">';
print $userstatic->getLoginUrl(1);
print '</td>';
// Todo Edit or delete button
// Action
if ($user->rights->produit->creer || $user->rights->service->creer) {
@ -534,24 +535,24 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</a>';
print '</td>';
}
print "</tr>\n";
}
print "</table>";
print "</form>";
} else {
print $langs->trans('None');
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n" . '<div class="tabsAction">' . "\n";
if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $soc->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
}

View File

@ -586,6 +586,10 @@ div.login {
height: 16px;
}
#securitycode {
min-width: 60px;
}
img.login, img.printer, img.entity {
margin:2px 0px 0px 0px;
text-decoration:none;

View File

@ -551,6 +551,9 @@ form#login {
background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%);
background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%);
}
#securitycode {
min-width: 60px;
}
#img_securitycode {
border: 1px solid #DDDDDD;
}

View File

@ -585,6 +585,9 @@ form#login {
background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%);
background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%);
}
#securitycode {
min-width: 60px;
}
#img_securitycode {
border: 1px solid #DDDDDD;
}

View File

@ -657,6 +657,9 @@ form#login {
background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%);
background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%);
}
#securitycode {
min-width: 60px;
}
#img_securitycode {
border: 1px solid #DDDDDD;
}

View File

@ -867,6 +867,9 @@ div#login_left, div#login_right {
table.login_table tr td table.none tr td {
padding: 2px;
}
#securitycode {
min-width: 60px;
}
#img_securitycode {
border: 1px solid #DDDDDD;
}