Merge remote-tracking branch 'origin/3.9' into develop
Conflicts: dev/initdata/savedemo.sh htdocs/filefunc.inc.php htdocs/user/card.php
This commit is contained in:
commit
2b1f57f01e
@ -1861,7 +1861,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac
|
||||
- Fix: [ bug #810 ] Cannot update ODT template path
|
||||
- Fix: [ bug #816 ] Sales journal does not reflect localtaxes
|
||||
- Fix: [ bug #817 ] Purchases journal does not reflect localtaxes
|
||||
- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionnary
|
||||
- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionary
|
||||
- Fix: [ bug #828 ] Error when code_region is not a number in llx_c_regions (with postgres)
|
||||
- Fix: [ bug #855 ] Holiday approval email in French
|
||||
- Fix: [ bug #856 ] (Holidays module) Mail error if destination user doesn't have an email
|
||||
@ -1880,7 +1880,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac
|
||||
- Fix: [ bug #736 ] Missing column in llx_c_chargesociales
|
||||
- Fix: Localtax2 for Spain must be based into buyer
|
||||
- Fix: [ bug #762 ] Bad profit calculation in Reporting
|
||||
- Fix: bug dictionnary with wrong prefix table
|
||||
- Fix: bug dictionary with wrong prefix table
|
||||
|
||||
***** ChangeLog for 3.3 compared to 3.2.* *****
|
||||
For users:
|
||||
@ -1968,7 +1968,7 @@ New experimental module:
|
||||
For developers:
|
||||
- New: Add webservice for thirdparty creation and list.
|
||||
- New: A module can overwrite templates parts.
|
||||
- New: Can add a link on title field of added dictionnary.
|
||||
- New: Can add a link on title field of added dictionary.
|
||||
- New: Uniformize code.
|
||||
- New: Add option WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER and
|
||||
WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER.
|
||||
|
||||
@ -6,7 +6,7 @@ Dolibarr ERP & CRM is a modern software to manage your organization's activity (
|
||||
|
||||
It's an Open Source software (wrote in PHP language) designed for small and medium companies, foundation and freelances.
|
||||
|
||||
You can freely use, study, modify or distribute it according to it's Free Software licence.
|
||||
You can freely use, study, modify or distribute it according to its Free Software licence.
|
||||
|
||||
You can use it as a standalone application or as a web application to be able to access it from the Internet or a LAN.
|
||||
|
||||
|
||||
@ -1159,10 +1159,13 @@ if ($nboftargetok) {
|
||||
if ($target eq 'SF') {
|
||||
$destFolder="$NEWPUBLISH/$filestoscan{$file}/".$MAJOR.'.'.$MINOR.'.'.$BUILD;
|
||||
}
|
||||
elsif ($target eq 'ASSO' && $NEWPUBLISH =~ /stable/) {
|
||||
elsif ($target eq 'ASSO' and $NEWPUBLISH =~ /stable/) {
|
||||
$destFolder="$NEWPUBLISH/$filestoscanstableasso{$file}";
|
||||
}
|
||||
else
|
||||
elsif ($target eq 'ASSO' and $NEWPUBLISH !~ /stable/) {
|
||||
$destFolder="$NEWPUBLISH";
|
||||
}
|
||||
else # No more used
|
||||
{
|
||||
$dirnameonly=$file;
|
||||
$dirnameonly =~ s/.*\/([^\/]+)\/[^\/]+$/$1/;
|
||||
|
||||
8217
dev/initdemo/mysqldump_dolibarr_3.9.0.sql
Normal file
8217
dev/initdemo/mysqldump_dolibarr_3.9.0.sql
Normal file
File diff suppressed because one or more lines are too long
@ -174,6 +174,10 @@ export list="
|
||||
--ignore-table=$base.llx_advanced_extrafields
|
||||
--ignore-table=$base.llx_advanced_extrafields_options
|
||||
--ignore-table=$base.llx_advanced_extrafields_values
|
||||
--ignore-table=$base.llx_askpricesupplier
|
||||
--ignore-table=$base.llx_askpricesupplier_extrafields
|
||||
--ignore-table=$base.llx_askpricesupplierdet
|
||||
--ignore-table=$base.llx_askpricesupplierdet_extrafields
|
||||
--ignore-table=$base.llx_bookkeeping
|
||||
--ignore-table=$base.llx_bootstrap
|
||||
--ignore-table=$base.llx_bt_namemap
|
||||
@ -196,6 +200,11 @@ export list="
|
||||
--ignore-table=$base.llx_cabinetmed_motifcons
|
||||
--ignore-table=$base.llx_cabinetmed_patient
|
||||
--ignore-table=$base.llx_cabinetmed_societe
|
||||
--ignore-table=$base.llx_congespayes
|
||||
--ignore-table=$base.llx_congespayes_config
|
||||
--ignore-table=$base.llx_congespayes_events
|
||||
--ignore-table=$base.llx_congespayes_logs
|
||||
--ignore-table=$base.llx_congespayes_users
|
||||
--ignore-table=$base.llx_dolicloud_customers
|
||||
--ignore-table=$base.llx_dolicloud_stats
|
||||
--ignore-table=$base.llx_dolicloud_emailstemplates
|
||||
@ -205,6 +214,7 @@ export list="
|
||||
--ignore-table=$base.llx_filemanager_roots
|
||||
--ignore-table=$base.llx_fournisseur_ca
|
||||
--ignore-table=$base.llx_google_maps
|
||||
--ignore-table=$base.llx_milestone
|
||||
--ignore-table=$base.llx_monitoring_probes
|
||||
--ignore-table=$base.llx_notes
|
||||
--ignore-table=$base.llx_pos_cash
|
||||
|
||||
@ -765,8 +765,11 @@ if (empty($reshook))
|
||||
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
|
||||
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
|
||||
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
|
||||
{
|
||||
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
}
|
||||
}
|
||||
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
|
||||
@ -2846,6 +2846,8 @@ class Propal extends CommonObject
|
||||
*/
|
||||
function getLinesArray()
|
||||
{
|
||||
// For other object, here we call fetch_lines. But fetch_lines does not exists on proposal
|
||||
|
||||
$sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
|
||||
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
|
||||
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2005-2015 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-2015 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2011-2016 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
@ -681,7 +681,7 @@ if (empty($reshook))
|
||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||
if (empty($tva_tx)) $tva_npr=0;
|
||||
|
||||
|
||||
$pu_ht = $prod->price;
|
||||
$pu_ttc = $prod->price_ttc;
|
||||
$price_min = $prod->price_min;
|
||||
@ -694,10 +694,11 @@ if (empty($reshook))
|
||||
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
|
||||
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
|
||||
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
|
||||
if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level];
|
||||
if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level];
|
||||
$tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
$tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
|
||||
{
|
||||
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
||||
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
||||
}
|
||||
}
|
||||
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
@ -1466,7 +1467,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
|
||||
{
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
$("#socid").change(function() {
|
||||
var socid = $(this).val();
|
||||
// reload page
|
||||
@ -2470,7 +2471,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
{
|
||||
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>';
|
||||
}
|
||||
|
||||
|
||||
// Create intervention
|
||||
if ($conf->ficheinter->enabled) {
|
||||
$langs->load("interventions");
|
||||
@ -2487,12 +2488,12 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
// Create contract
|
||||
if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED)) {
|
||||
$langs->load("contracts");
|
||||
|
||||
|
||||
if ($user->rights->contrat->creer) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/contrat/card.php?action=create&origin=' . $object->element . '&originid=' . $object->id . '&socid=' . $object->socid . '">' . $langs->trans('AddContract') . '</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ship
|
||||
$numshipping = 0;
|
||||
if (! empty($conf->expedition->enabled)) {
|
||||
@ -2559,6 +2560,11 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
// Select mail models is same action as presend
|
||||
if (GETPOST('modelselected')) {
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
if ($action != 'presend')
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
@ -2657,7 +2663,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
||||
{
|
||||
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
|
||||
}
|
||||
}
|
||||
$formmail->withfrom = 1;
|
||||
$liste = array();
|
||||
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value)
|
||||
|
||||
@ -1719,7 +1719,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
||||
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
||||
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
|
||||
$sql .= ' ORDER BY l.rang';
|
||||
$sql .= ' ORDER BY l.rang, l.rowid';
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -3283,12 +3283,14 @@ class Commande extends CommonOrder
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of order lines
|
||||
*
|
||||
* @return array Lines of order
|
||||
* Create an array of order lines
|
||||
*
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function getLinesArray()
|
||||
{
|
||||
return $this->fetch_lines();
|
||||
/*
|
||||
$lines = array();
|
||||
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx, ';
|
||||
@ -3367,7 +3369,7 @@ class Commande extends CommonOrder
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1154,7 +1154,7 @@ class Facture extends CommonInvoice
|
||||
$this->lines=array();
|
||||
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
|
||||
$sql .= ' l.situation_percent, l.fk_prev_id,';
|
||||
$sql.= ' l.situation_percent, l.fk_prev_id,';
|
||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
|
||||
$sql.= ' l.rang, l.special_code,';
|
||||
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
|
||||
@ -1165,7 +1165,7 @@ class Facture extends CommonInvoice
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= ' WHERE l.fk_facture = '.$this->id;
|
||||
$sql.= ' ORDER BY l.rang';
|
||||
$sql.= ' ORDER BY l.rang, l.rowid';
|
||||
|
||||
dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -3678,6 +3678,8 @@ class Facture extends CommonInvoice
|
||||
*/
|
||||
function getLinesArray()
|
||||
{
|
||||
return $this->fetch_lines();
|
||||
/*
|
||||
$sql = 'SELECT l.rowid, l.label as custom_label, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,';
|
||||
$sql.= ' l.fk_remise_except, l.localtax1_tx, l.localtax2_tx,';
|
||||
$sql .= ' l.situation_percent, l.fk_prev_id,';
|
||||
@ -3711,11 +3713,12 @@ class Facture extends CommonInvoice
|
||||
$this->lines[$i]->description = $obj->description;
|
||||
$this->lines[$i]->fk_product = $obj->fk_product;
|
||||
$this->lines[$i]->ref = $obj->product_ref;
|
||||
$this->lines[$i]->entity = $obj->entity; // Product entity
|
||||
$this->lines[$i]->product_label = $obj->product_label;
|
||||
$this->lines[$i]->product_ref = $obj->product_ref;
|
||||
$this->lines[$i]->product_label = $obj->product_label;
|
||||
$this->lines[$i]->product_desc = $obj->product_desc;
|
||||
$this->lines[$i]->fk_product_type = $obj->fk_product_type;
|
||||
$this->lines[$i]->product_type = $obj->product_type;
|
||||
$this->lines[$i]->entity = $obj->entity; // Product entity
|
||||
$this->lines[$i]->qty = $obj->qty;
|
||||
$this->lines[$i]->subprice = $obj->subprice;
|
||||
$this->lines[$i]->fk_remise_except = $obj->fk_remise_except;
|
||||
@ -3725,6 +3728,10 @@ class Facture extends CommonInvoice
|
||||
$this->lines[$i]->total_ht = $obj->total_ht;
|
||||
$this->lines[$i]->total_tva = $obj->total_tva;
|
||||
$this->lines[$i]->total_ttc = $obj->total_ttc;
|
||||
$this->lines[$i]->localtax1_tx = $obj->localtax1_tx;
|
||||
$this->lines[$i]->localtax2_tx = $obj->localtax2_tx;
|
||||
$this->lines[$i]->localtax1_type = $obj->localtax1_type;
|
||||
$this->lines[$i]->localtax2_type = $obj->localtax2_type;
|
||||
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
|
||||
$this->lines[$i]->situation_percent = $obj->situation_percent;
|
||||
$this->lines[$i]->fk_prev_id = $obj->fk_prev_id;
|
||||
@ -3757,7 +3764,7 @@ class Facture extends CommonInvoice
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -51,7 +51,7 @@ abstract class CommonObjectLine extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* Returns the text label from units dictionnary
|
||||
* Returns the text label from units dictionary
|
||||
*
|
||||
* @param string $type Label type (long or short)
|
||||
* @return string|int <0 if ko, label if ok
|
||||
|
||||
@ -227,7 +227,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
|
||||
* Return if a code is used (by other element)
|
||||
*
|
||||
* @param DoliDB $db Handler acces base
|
||||
* @param string $code Code a verifier
|
||||
* @param string $code Code to check
|
||||
* @param Product $product Objet product
|
||||
* @return int 0 if available, <0 if KO
|
||||
*/
|
||||
@ -277,12 +277,20 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
|
||||
return '';
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
|
||||
|
||||
$newcodefortest=$codefortest;
|
||||
|
||||
// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
|
||||
if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask
|
||||
{
|
||||
$newcodefortest=substr($newcodefortest,0,12);
|
||||
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
|
||||
{
|
||||
if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
|
||||
dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result=check_value($mask,$newcodefortest);
|
||||
|
||||
return $result;
|
||||
|
||||
@ -913,7 +913,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
// VAT
|
||||
foreach($this->tva as $tvakey => $tvaval)
|
||||
{
|
||||
if ($tvakey > 0) // On affiche pas taux 0
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
$this->atleastoneratenotnull++;
|
||||
|
||||
|
||||
@ -57,7 +57,6 @@ class pdf_proforma extends pdf_einstein
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show top header of page.
|
||||
*
|
||||
|
||||
@ -1112,7 +1112,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
// VAT
|
||||
foreach($this->tva as $tvakey => $tvaval)
|
||||
{
|
||||
if ($tvakey > 0) // On affiche pas taux 0
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
$this->atleastoneratenotnull++;
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ class modIncoterm extends DolibarrModules
|
||||
'tablib'=>array("Incoterms"), // Label of tables
|
||||
'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields
|
||||
'tabsqlsort'=>array("rowid ASC"), // Sort order
|
||||
'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionnary)
|
||||
'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary)
|
||||
'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)
|
||||
'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)
|
||||
'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')
|
||||
|
||||
@ -1075,7 +1075,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
// VAT
|
||||
foreach($this->tva as $tvakey => $tvaval)
|
||||
{
|
||||
if ($tvakey > 0) // On affiche pas taux 0
|
||||
if ($tvakey != 0) // On affiche pas taux 0
|
||||
{
|
||||
$this->atleastoneratenotnull++;
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ $price_level = GETPOST('price_level', 'int');
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$id = GETPOST('id', 'int');
|
||||
$price_by_qty_rowid = GETPOST('pbq', 'int');
|
||||
$finished = GETPOST('finished', 'int');
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -180,7 +181,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||
|
||||
$form = new Form($db);
|
||||
if (empty($mode) || $mode == 1) {
|
||||
$arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid);
|
||||
$arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid);
|
||||
} elseif ($mode == 2) {
|
||||
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid);
|
||||
}
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2007-2011 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2013-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2011-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2014 Henry Florian <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2014 Ion agorria <ion@agorria.com>
|
||||
* Copyright (C) 2014-2016 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2014 Ion agorria <ion@agorria.com>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -3943,7 +3943,7 @@ class Product extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text label from units dictionnary
|
||||
* Returns the text label from units dictionary
|
||||
*
|
||||
* @param string $type Label type (long or short)
|
||||
* @return string|int <0 if ko, label if ok
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013 Adolfo segura <adolfo.segura@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -79,6 +80,7 @@ if ($type === '0') { $contextpage='productlist'; if ($search_type=='') $search_t
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array($contextpage));
|
||||
$extrafields = new ExtraFields($db);
|
||||
$form=new Form($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('product');
|
||||
@ -120,6 +122,15 @@ if (! empty($conf->barcode->enabled)) {
|
||||
$fieldstosearchall['p.barcode']='Gencod';
|
||||
}
|
||||
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
{
|
||||
$titlesellprice=$langs->trans("SellingPrice");
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
$titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer"));
|
||||
}
|
||||
}
|
||||
|
||||
// Definition of fields for lists
|
||||
$arrayfields=array(
|
||||
'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||
@ -176,7 +187,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
|
||||
*/
|
||||
|
||||
$htmlother=new FormOther($db);
|
||||
$form=new Form($db);
|
||||
|
||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||
{
|
||||
@ -403,16 +413,7 @@ else
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if (empty($conf->global->PRODUIT_MULTIPRICES))
|
||||
{
|
||||
$titlesellprice=$langs->trans("SellingPrice");
|
||||
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
||||
{
|
||||
$titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer"));
|
||||
}
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
|
||||
@ -424,7 +425,7 @@ else
|
||||
if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,"",$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desirestock","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder);
|
||||
|
||||
@ -355,7 +355,7 @@ if (empty($reshook))
|
||||
$result=$object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessagess($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
@ -545,7 +545,7 @@ if ($action == 'create' && $user->rights->projet->creer)
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
|
||||
if (! empty($backtopage))
|
||||
{
|
||||
print ' ';
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* Version V1.1 Initial version of Philippe Berthet
|
||||
* Version V2 Change to be compatible with 3.4 and enhanced to be more generic
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
@ -79,6 +76,7 @@ $langs->load("suppliers");
|
||||
$langs->load("propal");
|
||||
$langs->load("interventions");
|
||||
$langs->load("contracts");
|
||||
$langs->load("products");
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('consumptionthirdparty'));
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
||||
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2015 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
||||
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
* Copyright (C) 2015 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -207,7 +207,7 @@ if (empty($reshook)) {
|
||||
$object->ldap_sid = GETPOST("ldap_sid");
|
||||
$object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0;
|
||||
$object->employee = GETPOST('employee');
|
||||
|
||||
|
||||
$object->thm = GETPOST("thm") != '' ? GETPOST("thm") : '';
|
||||
$object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : '';
|
||||
$object->salary = GETPOST("salary") != '' ? GETPOST("salary") : '';
|
||||
@ -257,15 +257,15 @@ if (empty($reshook)) {
|
||||
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
$db->rollback();
|
||||
if (is_array($object->errors) && count($object->errors))
|
||||
if (is_array($object->errors) && count($object->errors))
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action = "create"; // Go back to create page
|
||||
}
|
||||
}
|
||||
@ -291,8 +291,8 @@ if (empty($reshook)) {
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
@ -306,226 +306,212 @@ if (empty($reshook)) {
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
if (!$_POST["lastname"]) {
|
||||
setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
|
||||
$action = "edit"; // Go back to create page
|
||||
$error ++;
|
||||
if (!$_POST["lastname"]) {
|
||||
setEventMessages($langs->trans("NameNotDefined"), null, 'errors');
|
||||
$action = "edit"; // Go back to create page
|
||||
$error ++;
|
||||
}
|
||||
if (!$_POST["login"]) {
|
||||
setEventMessages($langs->trans("LoginNotDefined"), null, 'errors');
|
||||
$action = "edit"; // Go back to create page
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$object->fetch($id);
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$object->lastname = GETPOST("lastname", 'alpha');
|
||||
$object->firstname = GETPOST("firstname", 'alpha');
|
||||
$object->login = GETPOST("login", 'alpha');
|
||||
$object->gender = GETPOST("gender", 'alpha');
|
||||
$object->pass = GETPOST("password");
|
||||
$object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key;
|
||||
$object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin
|
||||
$object->address = GETPOST('address', 'alpha');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
$object->office_phone = GETPOST("office_phone", 'alpha');
|
||||
$object->office_fax = GETPOST("office_fax", 'alpha');
|
||||
$object->user_mobile = GETPOST("user_mobile");
|
||||
$object->skype = GETPOST("skype", 'alpha');
|
||||
$object->email = GETPOST("email", 'alpha');
|
||||
$object->job = GETPOST("job", 'alpha');
|
||||
$object->signature = GETPOST("signature");
|
||||
$object->accountancy_code = GETPOST("accountancy_code");
|
||||
$object->openid = GETPOST("openid");
|
||||
$object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0;
|
||||
$object->employee = GETPOST('employee');
|
||||
|
||||
$object->thm = GETPOST("thm") != '' ? GETPOST("thm") : '';
|
||||
$object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : '';
|
||||
$object->salary = GETPOST("salary") != '' ? GETPOST("salary") : '';
|
||||
$object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : '';
|
||||
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
|
||||
|
||||
$object->color = GETPOST("color") != '' ? GETPOST("color") : '';
|
||||
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (! empty($_POST["superadmin"]))
|
||||
{
|
||||
$object->entity = 0;
|
||||
}
|
||||
else if ($conf->multicompany->transverse_mode)
|
||||
{
|
||||
$object->entity = 1; // all users in master entity
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int'));
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0) {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (GETPOST('deletephoto')) {
|
||||
$object->photo = '';
|
||||
}
|
||||
if (!empty($_FILES['photo']['name'])) {
|
||||
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$ret = $object->update($user);
|
||||
if ($ret < 0) {
|
||||
$error ++;
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && isset($_POST['contactid'])) {
|
||||
$contactid = GETPOST('contactid', 'int');
|
||||
|
||||
if ($contactid > 0) {
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($contactid);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
$sql .= " SET fk_socpeople=".$db->escape($contactid);
|
||||
if (!empty($contact->socid)) {
|
||||
$sql .= ", fk_soc=".$db->escape($contact->socid);
|
||||
}
|
||||
$sql .= " WHERE rowid=".$object->id;
|
||||
} else {
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
$sql .= " SET fk_socpeople=NULL, fk_soc=NULL";
|
||||
$sql .= " WHERE rowid=".$object->id;
|
||||
}
|
||||
dol_syslog("usercard::update", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
$error ++;
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !count($object->errors)) {
|
||||
if (GETPOST('deletephoto') && $object->photo) {
|
||||
$fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo;
|
||||
$dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs';
|
||||
dol_delete_file($fileimg);
|
||||
dol_delete_dir_recursive($dirthumbs);
|
||||
}
|
||||
|
||||
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) {
|
||||
$dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user');
|
||||
|
||||
dol_mkdir($dir);
|
||||
|
||||
if (@is_dir($dir)) {
|
||||
$newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']);
|
||||
|
||||
if (!$result > 0) {
|
||||
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
|
||||
} else {
|
||||
// Create small thumbs for company (Ratio is near 16/9)
|
||||
// Used on logon for example
|
||||
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
||||
|
||||
// Create mini thumbs for company (Ratio is near 16/9)
|
||||
// Used on menu or for setup page for example
|
||||
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error && ! count($object->errors))
|
||||
{
|
||||
// Then we add the associated categories
|
||||
$categories = GETPOST( 'usercats', 'array' );
|
||||
$object->setCategories($categories);
|
||||
}
|
||||
|
||||
if (!$error && !count($object->errors)) {
|
||||
setEventMessages($langs->trans("UserModified"), null, 'mesgs');
|
||||
$db->commit();
|
||||
|
||||
$login = $_SESSION["dol_login"];
|
||||
if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$_POST["login"]) {
|
||||
setEventMessages($langs->trans("LoginNotDefined"), null, 'errors');
|
||||
$action = "edit"; // Go back to create page
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$object->fetch($id);
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$object->lastname = GETPOST("lastname", 'alpha');
|
||||
$object->firstname = GETPOST("firstname", 'alpha');
|
||||
$object->login = GETPOST("login", 'alpha');
|
||||
$object->gender = GETPOST("gender", 'alpha');
|
||||
$object->pass = GETPOST("password");
|
||||
$object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key;
|
||||
$object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin
|
||||
$object->address = GETPOST('address', 'alpha');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
$object->office_phone = GETPOST("office_phone", 'alpha');
|
||||
$object->office_fax = GETPOST("office_fax", 'alpha');
|
||||
$object->user_mobile = GETPOST("user_mobile");
|
||||
$object->skype = GETPOST("skype", 'alpha');
|
||||
$object->email = GETPOST("email", 'alpha');
|
||||
$object->job = GETPOST("job", 'alpha');
|
||||
$object->signature = GETPOST("signature");
|
||||
$object->accountancy_code = GETPOST("accountancy_code");
|
||||
$object->openid = GETPOST("openid");
|
||||
$object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0;
|
||||
$object->employee = GETPOST('employee');
|
||||
|
||||
$object->thm = GETPOST("thm") != '' ? GETPOST("thm") : '';
|
||||
$object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : '';
|
||||
$object->salary = GETPOST("salary") != '' ? GETPOST("salary") : '';
|
||||
$object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : '';
|
||||
$object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : '';
|
||||
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (! empty($_POST["superadmin"]))
|
||||
{
|
||||
$object->entity = 0;
|
||||
}
|
||||
else if ($conf->multicompany->transverse_mode)
|
||||
{
|
||||
$object->entity = 1; // all users in master entity
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int'));
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0) {
|
||||
$error ++;
|
||||
}
|
||||
|
||||
if (!empty($conf->multicompany->enabled)) {
|
||||
if (!empty($_POST["superadmin"])) {
|
||||
$object->entity = 0;
|
||||
} else {
|
||||
if ($conf->multicompany->transverse_mode) {
|
||||
$object->entity = 1; // all users in master entity
|
||||
} else {
|
||||
$object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]);
|
||||
}
|
||||
|
||||
if (GETPOST('deletephoto')) {
|
||||
$object->photo = '';
|
||||
}
|
||||
if (!empty($_FILES['photo']['name'])) {
|
||||
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$ret = $object->update($user);
|
||||
if ($ret < 0) {
|
||||
$error ++;
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && isset($_POST['contactid'])) {
|
||||
$contactid = GETPOST('contactid');
|
||||
|
||||
if ($contactid > 0) {
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($contactid);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
$sql .= " SET fk_socpeople=".$db->escape($contactid);
|
||||
if ($contact->socid) {
|
||||
$sql .= ", fk_soc=".$db->escape($contact->socid);
|
||||
}
|
||||
$sql .= " WHERE rowid=".$object->id;
|
||||
} else {
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
$sql .= " SET fk_socpeople=NULL, fk_soc=NULL";
|
||||
$sql .= " WHERE rowid=".$object->id;
|
||||
}
|
||||
dol_syslog("fiche::update", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
$error ++;
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !count($object->errors)) {
|
||||
if (GETPOST('deletephoto') && $object->photo) {
|
||||
$fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo;
|
||||
$dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs';
|
||||
dol_delete_file($fileimg);
|
||||
dol_delete_dir_recursive($dirthumbs);
|
||||
}
|
||||
|
||||
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) {
|
||||
$dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user');
|
||||
|
||||
dol_mkdir($dir);
|
||||
|
||||
if (@is_dir($dir)) {
|
||||
$newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']);
|
||||
|
||||
if (!$result > 0) {
|
||||
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
|
||||
} else {
|
||||
// Create small thumbs for company (Ratio is near 16/9)
|
||||
// Used on logon for example
|
||||
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
|
||||
|
||||
// Create mini thumbs for company (Ratio is near 16/9)
|
||||
// Used on menu or for setup page for example
|
||||
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
|
||||
}
|
||||
} else {
|
||||
$error ++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $error && ! count($object->errors))
|
||||
{
|
||||
// Then we add the associated categories
|
||||
$categories = GETPOST( 'usercats', 'array' );
|
||||
$object->setCategories($categories);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($caneditpassword) // Case we can edit only password
|
||||
{
|
||||
dol_syslog("Not allowed to change fields, only password");
|
||||
|
||||
$object->fetch($id);
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$ret = $object->setPassword($user, GETPOST("password"));
|
||||
if ($ret < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !count($object->errors)) {
|
||||
setEventMessages($langs->trans("UserModified"), null, 'mesgs');
|
||||
$db->commit();
|
||||
|
||||
$login = $_SESSION["dol_login"];
|
||||
if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
|
||||
}
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($caneditpassword) // Case we can edit only password
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$ret = $object->setPassword($user, $_POST["password"]);
|
||||
if ($ret < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$object->oldcopy = clone $object;
|
||||
|
||||
$ret=$object->setPassword($user,$_POST["password"]);
|
||||
if ($ret < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change password with a new generated one
|
||||
if ((($action == 'confirm_password' && $confirm == 'yes')
|
||||
@ -540,18 +526,18 @@ if (empty($reshook)) {
|
||||
} else {
|
||||
// Succes
|
||||
if ($action == 'confirm_passwordsend' && $confirm == 'yes') {
|
||||
if ($object->send_password($user, $newpassword) > 0)
|
||||
if ($object->send_password($user, $newpassword) > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'errors');
|
||||
setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -603,8 +589,8 @@ if (empty($reshook)) {
|
||||
$ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
||||
}
|
||||
@ -935,7 +921,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
print $formcompany->select_state($object->state_id,$object->country_code, 'state_id');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Tel
|
||||
print '<tr><td>'.$langs->trans("PhonePro").'</td>';
|
||||
print '<td>';
|
||||
@ -1782,13 +1768,14 @@ else
|
||||
|
||||
dol_fiche_head($head, 'user', $title, 0, 'user');
|
||||
|
||||
$rowspan=17;
|
||||
$rowspan=22;
|
||||
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++;
|
||||
if (! empty($conf->societe->enabled)) $rowspan++;
|
||||
if (! empty($conf->adherent->enabled)) $rowspan++;
|
||||
if (! empty($conf->skype->enabled)) $rowspan++;
|
||||
if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3;
|
||||
if (! empty($conf->agenda->enabled)) $rowspan++;
|
||||
if (! empty($conf->accounting->enabled)) $rowspan++;
|
||||
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Copyright (c) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2005 Lionel Cousteix <etm_ltd@tiscali.co.uk>
|
||||
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
|
||||
* Copyright (C) 2013-2014 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
@ -138,11 +138,11 @@ class User extends CommonObject
|
||||
|
||||
// For cache usage
|
||||
$this->all_permissions_are_loaded = 0;
|
||||
|
||||
// Force some default values
|
||||
|
||||
// Force some default values
|
||||
$this->admin = 0;
|
||||
$this->employee = 1;
|
||||
|
||||
|
||||
$this->conf = new stdClass();
|
||||
$this->rights = new stdClass();
|
||||
$this->rights->user = new stdClass();
|
||||
@ -202,14 +202,14 @@ class User extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
|
||||
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
|
||||
}
|
||||
}
|
||||
else // The fetch was forced on an entity
|
||||
{
|
||||
$sql.= " WHERE u.entity IN (0, ".$conf->entity.")";
|
||||
}
|
||||
|
||||
|
||||
if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba
|
||||
{
|
||||
$sql.= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1";
|
||||
@ -239,7 +239,7 @@ class User extends CommonObject
|
||||
$this->ldap_sid = $obj->ldap_sid;
|
||||
$this->lastname = $obj->lastname;
|
||||
$this->firstname = $obj->firstname;
|
||||
|
||||
|
||||
$this->employee = $obj->employee;
|
||||
|
||||
$this->login = $obj->login;
|
||||
@ -298,8 +298,8 @@ class User extends CommonObject
|
||||
|
||||
// Protection when module multicompany was set, admin was set to first entity and the module disabled,
|
||||
// then this admin user must be admin for all entities.
|
||||
if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0;
|
||||
|
||||
if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0;
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
// fetch optionals attributes and labels
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
@ -1271,7 +1271,7 @@ class User extends CommonObject
|
||||
$this->error = $langs->trans("ErrorFieldRequired",$this->login);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Update datas
|
||||
@ -1316,7 +1316,7 @@ class User extends CommonObject
|
||||
$nbrowsaffected+=$this->db->affected_rows($resql);
|
||||
|
||||
// Update password
|
||||
if ($this->pass)
|
||||
if (!empty($this->pass))
|
||||
{
|
||||
if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted)
|
||||
{
|
||||
@ -1937,7 +1937,7 @@ class User extends CommonObject
|
||||
global $menumanager;
|
||||
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
|
||||
|
||||
|
||||
$result = '';
|
||||
$companylink = '';
|
||||
$link = '';
|
||||
@ -1991,11 +1991,11 @@ class User extends CommonObject
|
||||
$link.= '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'"';
|
||||
if (empty($notooltip))
|
||||
{
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
$langs->load("users");
|
||||
$label=$langs->trans("ShowUser");
|
||||
$link.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
$link.=' alt="'.dol_escape_htmltag($label, 1).'"';
|
||||
}
|
||||
$link.= ' title="'.dol_escape_htmltag($label, 1).'"';
|
||||
$link.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
|
||||
@ -2013,7 +2013,7 @@ class User extends CommonObject
|
||||
else $picto='<div class="inline-block valignmiddle'.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'</div>';
|
||||
$result.=$picto;
|
||||
}
|
||||
if (abs($withpictoimg) != 2)
|
||||
if (abs($withpictoimg) != 2)
|
||||
{
|
||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='<div class="inline-block valignmiddle'.((! isset($this->statut) || $this->statut)?'':' strikefordisabled').($morecss?' usertext'.$morecss:'').'">';
|
||||
if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen);
|
||||
@ -2627,8 +2627,8 @@ class User extends CommonObject
|
||||
|
||||
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Charge indicateurs this->nb pour le tableau de bord
|
||||
*
|
||||
@ -2663,6 +2663,6 @@ class User extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user