Fix fix as Eldy wish it
This commit is contained in:
parent
738ed467b3
commit
e2d0d0d414
@ -62,8 +62,7 @@ if ($action == 'STOCK_CALCULATE_ON_BILL'
|
|||||||
// Mode of stock increase
|
// Mode of stock increase
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
|
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'
|
||||||
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'
|
|| $action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')
|
||||||
|| $action == 'STOCK_CALCULATE_ON_DELETE_INVOICE')
|
|
||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
|
$res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", '','chaine',0,'',$conf->entity);
|
||||||
@ -73,7 +72,6 @@ if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL'
|
|||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_BILL') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_BILL", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_BILL','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
if ($action == 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", GETPOST('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER','alpha'),'chaine',0,'',$conf->entity);
|
||||||
if ($action == 'STOCK_CALCULATE_ON_DELETE_INVOICE') $res=dolibarr_set_const($db, "STOCK_CALCULATE_ON_DELETE_INVOICE", GETPOST('STOCK_CALCULATE_ON_DELETE_INVOICE','alpha'),'chaine',0,'',$conf->entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action)
|
if($action)
|
||||||
|
|||||||
@ -1,34 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||||
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
|
* Copyright (C) 2013 Jean-Francois FERRY <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/compta/facture.php
|
* \file htdocs/compta/facture.php
|
||||||
* \ingroup facture
|
* \ingroup facture
|
||||||
* \brief Page to create/see an invoice
|
* \brief Page to create/see an invoice
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||||
@ -99,7 +99,7 @@ $hookmanager->initHooks(array('invoicecard'));
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$parameters=array('socid'=>$socid);
|
$parameters=array('socid'=>$socid);
|
||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
@ -159,15 +159,14 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fact
|
|||||||
|
|
||||||
$idwarehouse=GETPOST('idwarehouse');
|
$idwarehouse=GETPOST('idwarehouse');
|
||||||
|
|
||||||
//Check for warehouse
|
$qualified_for_stock_change=0;
|
||||||
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_DELETE_INVOICE) && $object->hasProductsOrServices(1) && $object->statut>=1)
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
{
|
{
|
||||||
if (! $idwarehouse || $idwarehouse == -1)
|
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")),'errors');
|
|
||||||
$action='';
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->delete(0,0,$idwarehouse);
|
$result = $object->delete(0,0,$idwarehouse);
|
||||||
@ -403,8 +402,18 @@ else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->factu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$qualified_for_stock_change=0;
|
||||||
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||||
|
}
|
||||||
|
|
||||||
//Check for warehouse
|
//Check for warehouse
|
||||||
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
|
||||||
{
|
{
|
||||||
if (! $idwarehouse || $idwarehouse == -1)
|
if (! $idwarehouse || $idwarehouse == -1)
|
||||||
{
|
{
|
||||||
@ -450,8 +459,18 @@ else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
|
$qualified_for_stock_change=0;
|
||||||
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
|
||||||
{
|
{
|
||||||
if (! $idwarehouse || $idwarehouse == -1)
|
if (! $idwarehouse || $idwarehouse == -1)
|
||||||
{
|
{
|
||||||
@ -626,7 +645,7 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert new invoice in database
|
* Insert new invoice in database
|
||||||
*/
|
*/
|
||||||
else if ($action == 'add' && $user->rights->facture->creer)
|
else if ($action == 'add' && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
if ($socid>0)
|
if ($socid>0)
|
||||||
@ -823,11 +842,21 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($element == 'order') { $element = $subelement = 'commande'; }
|
if ($element == 'order') {
|
||||||
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
$element = $subelement = 'commande';
|
||||||
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
}
|
||||||
if ($element == 'inter') { $element = $subelement = 'ficheinter'; }
|
if ($element == 'propal') {
|
||||||
if ($element == 'shipping') { $element = $subelement = 'expedition'; }
|
$element = 'comm/propal'; $subelement = 'propal';
|
||||||
|
}
|
||||||
|
if ($element == 'contract') {
|
||||||
|
$element = $subelement = 'contrat';
|
||||||
|
}
|
||||||
|
if ($element == 'inter') {
|
||||||
|
$element = $subelement = 'ficheinter';
|
||||||
|
}
|
||||||
|
if ($element == 'shipping') {
|
||||||
|
$element = $subelement = 'expedition';
|
||||||
|
}
|
||||||
|
|
||||||
$object->origin = $_POST['origin'];
|
$object->origin = $_POST['origin'];
|
||||||
$object->origin_id = $_POST['originid'];
|
$object->origin_id = $_POST['originid'];
|
||||||
@ -1437,7 +1466,7 @@ else if ($action == 'down' && $user->rights->facture->creer)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Add file in email form
|
* Add file in email form
|
||||||
*/
|
*/
|
||||||
if (GETPOST('addfile'))
|
if (GETPOST('addfile'))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
@ -1452,7 +1481,7 @@ if (GETPOST('addfile'))
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove file in email form
|
* Remove file in email form
|
||||||
*/
|
*/
|
||||||
if (! empty($_POST['removedfile']))
|
if (! empty($_POST['removedfile']))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
@ -1468,7 +1497,7 @@ if (! empty($_POST['removedfile']))
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Send mail
|
* Send mail
|
||||||
*/
|
*/
|
||||||
if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
|
if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
|
||||||
{
|
{
|
||||||
$langs->load('mails');
|
$langs->load('mails');
|
||||||
@ -1480,11 +1509,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// $ref = dol_sanitizeFileName($object->ref);
|
// $ref = dol_sanitizeFileName($object->ref);
|
||||||
// $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
// $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||||
|
|
||||||
// if (is_readable($file))
|
// if (is_readable($file))
|
||||||
// {
|
// {
|
||||||
if ($_POST['sendto'])
|
if ($_POST['sendto'])
|
||||||
{
|
{
|
||||||
// Le destinataire a ete fourni via le champ libre
|
// Le destinataire a ete fourni via le champ libre
|
||||||
@ -1579,7 +1608,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($db);
|
$interface=new Interfaces($db);
|
||||||
$result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf);
|
$result=$interface->run_triggers('BILL_SENTBYMAIL',$object,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
if ($result < 0) {
|
||||||
|
$error++; $this->errors=$interface->errors;
|
||||||
|
}
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
@ -1613,7 +1644,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
$mesgs[]=$mesg;
|
$mesgs[]=$mesg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }
|
/* }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$langs->load("other");
|
$langs->load("other");
|
||||||
@ -1636,13 +1667,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||||||
}
|
}
|
||||||
|
|
||||||
$action = 'presend';
|
$action = 'presend';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate document
|
* Generate document
|
||||||
*/
|
*/
|
||||||
else if ($action == 'builddoc') // En get ou en post
|
else if ($action == 'builddoc') // En get ou en post
|
||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
@ -1670,11 +1701,11 @@ else if ($action == 'builddoc') // En get ou en post
|
|||||||
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove file in doc form
|
// Remove file in doc form
|
||||||
else if ($action == 'remove_file')
|
else if ($action == 'remove_file')
|
||||||
{
|
{
|
||||||
if ($object->fetch($id))
|
if ($object->fetch($id))
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
@ -1689,10 +1720,10 @@ else if ($action == 'remove_file')
|
|||||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
|
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
if ($action == 'addcontact')
|
if ($action == 'addcontact')
|
||||||
{
|
{
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
@ -1750,10 +1781,10 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
|
|||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'update_extras')
|
if ($action == 'update_extras')
|
||||||
{
|
{
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
@ -1776,30 +1807,30 @@ if ($action == 'update_extras')
|
|||||||
}
|
}
|
||||||
else if ($reshook < 0) $error++;
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formother=new FormOther($db);
|
$formother=new FormOther($db);
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
$bankaccountstatic=new Account($db);
|
$bankaccountstatic=new Account($db);
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
|
llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
*
|
*
|
||||||
* Mode creation
|
* Mode creation
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
$facturestatic=new Facture($db);
|
$facturestatic=new Facture($db);
|
||||||
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
||||||
|
|
||||||
@ -1825,10 +1856,18 @@ if ($action == 'create')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; }
|
if ($element == 'order' || $element == 'commande') {
|
||||||
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
$element = $subelement = 'commande';
|
||||||
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
}
|
||||||
if ($element == 'shipping') { $element = $subelement = 'expedition'; }
|
if ($element == 'propal') {
|
||||||
|
$element = 'comm/propal'; $subelement = 'propal';
|
||||||
|
}
|
||||||
|
if ($element == 'contract') {
|
||||||
|
$element = $subelement = 'contrat';
|
||||||
|
}
|
||||||
|
if ($element == 'shipping') {
|
||||||
|
$element = $subelement = 'expedition';
|
||||||
|
}
|
||||||
|
|
||||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
|
|
||||||
@ -2271,9 +2310,9 @@ if ($action == 'create')
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ($id > 0 || ! empty($ref))
|
else if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Show object in view mode
|
* Show object in view mode
|
||||||
*/
|
*/
|
||||||
@ -2350,7 +2389,18 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
$text=$langs->trans('ConfirmDeleteBill',$object->ref);
|
$text=$langs->trans('ConfirmDeleteBill',$object->ref);
|
||||||
$formquestion=array();
|
$formquestion=array();
|
||||||
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_DELETE_INVOICE) && $object->hasProductsOrServices(1) && $object->statut>=1)
|
|
||||||
|
$qualified_for_stock_change=0;
|
||||||
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change && $object->statut>=1)
|
||||||
{
|
{
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||||
@ -2360,7 +2410,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
//'text' => $langs->trans("ConfirmClone"),
|
//'text' => $langs->trans("ConfirmClone"),
|
||||||
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
//array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
||||||
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
|
//array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
|
||||||
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1)));
|
array('type' => 'other', 'name' => 'idwarehouse', 'label' => $label, 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1,0,0,$langs->trans("NoStockAction"))));
|
||||||
$formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete',$formquestion,"yes",1);
|
$formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete',$formquestion,"yes",1);
|
||||||
}else {
|
}else {
|
||||||
$formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete','','',1);
|
$formconfirm=$form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id,$langs->trans('DeleteBill'),$text,'confirm_delete','','',1);
|
||||||
@ -2398,7 +2448,17 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
$formquestion=array();
|
$formquestion=array();
|
||||||
|
|
||||||
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
$qualified_for_stock_change=0;
|
||||||
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
|
||||||
{
|
{
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||||
@ -2422,7 +2482,17 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
$text=$langs->trans('ConfirmUnvalidateBill',$object->ref);
|
$text=$langs->trans('ConfirmUnvalidateBill',$object->ref);
|
||||||
$formquestion=array();
|
$formquestion=array();
|
||||||
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1))
|
|
||||||
|
$qualified_for_stock_change=0;
|
||||||
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qualified_for_stock_change=$object->hasProductsOrServices(1);
|
||||||
|
}
|
||||||
|
if ($object->type != 3 && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
|
||||||
{
|
{
|
||||||
$langs->load("stocks");
|
$langs->load("stocks");
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||||
@ -3633,10 +3703,10 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
dol_print_error($db,$object->error);
|
dol_print_error($db,$object->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_htmloutput_mesg('',$mesgs);
|
dol_htmloutput_mesg('',$mesgs);
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -1298,7 +1298,7 @@ class Facture extends CommonInvoice
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we decrament stock on invoice validation, we increment
|
// If we decrament stock on invoice validation, we increment
|
||||||
if ($this->type != 3 && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_DELETE_INVOICE))
|
if ($this->type != 3 && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse!=-1)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||||
$langs->load("agenda");
|
$langs->load("agenda");
|
||||||
|
|||||||
@ -2310,7 +2310,7 @@ abstract class CommonObject
|
|||||||
/**
|
/**
|
||||||
* Function to say how many lines object contains
|
* Function to say how many lines object contains
|
||||||
*
|
*
|
||||||
* @param int $predefined -1=All, 0=Count free product/service only, 1=Count predefined product/service only
|
* @param int $predefined -1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service
|
||||||
* @return int <0 if KO, 0 if no predefined products, nb of lines with predefined products if found
|
* @return int <0 if KO, 0 if no predefined products, nb of lines with predefined products if found
|
||||||
*/
|
*/
|
||||||
function hasProductsOrServices($predefined=-1)
|
function hasProductsOrServices($predefined=-1)
|
||||||
@ -2323,6 +2323,8 @@ abstract class CommonObject
|
|||||||
if ($predefined == -1) $qualified=1;
|
if ($predefined == -1) $qualified=1;
|
||||||
if ($predefined == 1 && $val->fk_product > 0) $qualified=1;
|
if ($predefined == 1 && $val->fk_product > 0) $qualified=1;
|
||||||
if ($predefined == 0 && $val->fk_product <= 0) $qualified=1;
|
if ($predefined == 0 && $val->fk_product <= 0) $qualified=1;
|
||||||
|
if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) $qualified=1;
|
||||||
|
if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) $qualified=1;
|
||||||
if ($qualified) $nb++;
|
if ($qualified) $nb++;
|
||||||
}
|
}
|
||||||
dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies');
|
dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies');
|
||||||
|
|||||||
@ -87,4 +87,5 @@ PersonalStock=Personal stock %s
|
|||||||
ThisWarehouseIsPersonalStock=This warehouse represents personal stock of %s %s
|
ThisWarehouseIsPersonalStock=This warehouse represents personal stock of %s %s
|
||||||
SelectWarehouseForStockDecrease=Choose warehouse to use for stock decrease
|
SelectWarehouseForStockDecrease=Choose warehouse to use for stock decrease
|
||||||
SelectWarehouseForStockIncrease=Choose warehouse to use for stock increase
|
SelectWarehouseForStockIncrease=Choose warehouse to use for stock increase
|
||||||
|
NoStockAction=No stock action
|
||||||
LastWaitingSupplierOrders=Orders waiting for receptions
|
LastWaitingSupplierOrders=Orders waiting for receptions
|
||||||
@ -86,4 +86,5 @@ PersonalStock=Stock personal %s
|
|||||||
ThisWarehouseIsPersonalStock=Este almacén representa el stock personal de %s %s
|
ThisWarehouseIsPersonalStock=Este almacén representa el stock personal de %s %s
|
||||||
SelectWarehouseForStockDecrease=Seleccione el almacén a usar en el decremento de stock
|
SelectWarehouseForStockDecrease=Seleccione el almacén a usar en el decremento de stock
|
||||||
SelectWarehouseForStockIncrease=Seleccione el almacén a usar en el incremento de stock
|
SelectWarehouseForStockIncrease=Seleccione el almacén a usar en el incremento de stock
|
||||||
|
NoStockAction=Sin acciones sobre el stock
|
||||||
LastWaitingSupplierOrders=Pedidos en espera de recepción
|
LastWaitingSupplierOrders=Pedidos en espera de recepción
|
||||||
@ -87,4 +87,5 @@ PersonalStock=Stock personnel %s
|
|||||||
ThisWarehouseIsPersonalStock=Cet entrepôt représente le stock personnel de %s %s
|
ThisWarehouseIsPersonalStock=Cet entrepôt représente le stock personnel de %s %s
|
||||||
SelectWarehouseForStockDecrease=Sélectionner l'entrepôt à utiliser pour la décrémentation du stock
|
SelectWarehouseForStockDecrease=Sélectionner l'entrepôt à utiliser pour la décrémentation du stock
|
||||||
SelectWarehouseForStockIncrease=Sélectionner l'entrepôt à utiliser pour l'incrémentation du stock
|
SelectWarehouseForStockIncrease=Sélectionner l'entrepôt à utiliser pour l'incrémentation du stock
|
||||||
|
NoStockAction=Pas d'action sur l'entrepot
|
||||||
LastWaitingSupplierOrders=Commandes en attente de réception
|
LastWaitingSupplierOrders=Commandes en attente de réception
|
||||||
@ -109,9 +109,10 @@ class FormProduct
|
|||||||
* @param int $empty 1=Can be empty, 0 if not
|
* @param int $empty 1=Can be empty, 0 if not
|
||||||
* @param int $disabled 1=Select is disabled
|
* @param int $disabled 1=Select is disabled
|
||||||
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
|
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
|
||||||
|
* @param string $empty_label Empty label if needed (only if $empty=1)
|
||||||
* @return string HTML select
|
* @return string HTML select
|
||||||
*/
|
*/
|
||||||
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0)
|
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='')
|
||||||
{
|
{
|
||||||
global $langs,$user;
|
global $langs,$user;
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ class FormProduct
|
|||||||
$this->loadWarehouses($fk_product);
|
$this->loadWarehouses($fk_product);
|
||||||
|
|
||||||
$out='<select class="flat"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.($htmlname.($disabled?'_disabled':'')).'">';
|
$out='<select class="flat"'.($disabled?' disabled="disabled"':'').' id="'.$htmlname.'" name="'.($htmlname.($disabled?'_disabled':'')).'">';
|
||||||
if ($empty) $out.='<option value="-1"> </option>';
|
if ($empty) $out.='<option value="-1">'.($empty_label?$empty_label:' ').'</option>';
|
||||||
foreach($this->cache_warehouses as $id => $arraytypes)
|
foreach($this->cache_warehouses as $id => $arraytypes)
|
||||||
{
|
{
|
||||||
$out.='<option value="'.$id.'"';
|
$out.='<option value="'.$id.'"';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user