Merge branch 'develop' of github.com:Dolibarr/dolibarr into new_branch_30_08_2018

This commit is contained in:
Philippe GRAND 2018-08-31 16:37:03 +02:00
commit 6474646e4b
4 changed files with 40 additions and 148 deletions

View File

@ -49,22 +49,22 @@ class Propal extends CommonObject
* @var string ID to identify managed object
*/
public $element='propal';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element='propal';
public $table_element_line='propaldet';
public $fk_element='fk_propal';
public $picto='propal';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
@ -1574,10 +1574,10 @@ class Propal extends CommonObject
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
$sql.= ' d.fk_unit,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobach as product_batch,';
$sql.= ' p.weight, p.weight_units, p.volume, p.volume_units,';
$sql.= ' d.date_start, d.date_end';
$sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql.= ' d.date_start, d.date_end,';
$sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)';
$sql.= ' WHERE d.fk_propal = '.$this->id;
@ -1639,7 +1639,8 @@ class Propal extends CommonObject
$line->libelle = $objp->product_label; // TODO deprecated
$line->product_label = $objp->product_label;
$line->product_desc = $objp->product_desc; // Description produit
$line->fk_product_type = $objp->fk_product_type;
$line->product_tobatch = $objp->product_tobatch;
$line->fk_product_type = $objp->fk_product_type; // TODO deprecated
$line->fk_unit = $objp->fk_unit;
$line->weight = $objp->weight;
$line->weight_units = $objp->weight_units;
@ -3201,7 +3202,7 @@ class Propal extends CommonObject
{
$response->nbtodo++;
$response->total+=$obj->total_ht;
if ($mode == 'opened')
{
$datelimit = $this->db->jdate($obj->datefin);
@ -3511,8 +3512,8 @@ class Propal extends CommonObject
*/
function getLinesArray()
{
// TODO Duplicate with fetch_lines ? Wich one to keep ?
return $this->fetch_lines();
/*
$this->lines = array();
$sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
@ -3601,7 +3602,7 @@ class Propal extends CommonObject
{
$this->error=$this->db->error();
return -1;
}
}*/
}
/**
@ -3665,7 +3666,7 @@ class PropaleLigne extends CommonObjectLine
* @var string ID to identify managed object
*/
public $element='propaldet';
/**
* @var string Name of table without prefix where object is stored
*/

View File

@ -1771,7 +1771,7 @@ function getSoapParams()
*/
function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='')
{
global $db,$conf;
global $db, $conf, $langs;
$ret='';

View File

@ -511,9 +511,18 @@ if ($id > 0 || ! empty($ref)) {
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Description") . '</td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
if (! empty($conf->productbatch->enabled))
{
print '<td>' . $langs->trans("batch_number") . '</td>';
print '<td>' . $langs->trans("EatByDate") . '</td>';
print '<td>' . $langs->trans("SellByDate") . '</td>';
}
else
{
print '<td></td>';
print '<td></td>';
print '<td></td>';
}
print '<td align="right">' . $langs->trans("SupplierRef") . '</td>';
print '<td align="right">' . $langs->trans("QtyOrdered") . '</td>';
print '<td align="right">' . $langs->trans("QtyDispatchedShort") . '</td>';
@ -521,16 +530,6 @@ if ($id > 0 || ! empty($ref)) {
print '<td width="32"></td>';
print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
print "</tr>\n";
if (! empty($conf->productbatch->enabled)) {
print '<tr class="liste_titre">';
print '<td></td>';
print '<td>' . $langs->trans("batch_number") . '</td>';
print '<td>' . $langs->trans("EatByDate") . '</td>';
print '<td>' . $langs->trans("SellByDate") . '</td>';
print '<td colspan="5">&nbsp;</td>';
print "</tr>\n";
}
}
$nbfreeproduct = 0; // Nb of lins of free products/services
@ -593,7 +592,7 @@ if ($id > 0 || ! empty($ref)) {
// Supplier ref
print '<td align="right">'.$objp->sref.'</td>';
// Qty ordered
print '<td align="right">' . $objp->qty . '</td>';
@ -638,7 +637,7 @@ if ($id > 0 || ! empty($ref)) {
$dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo' . $suffix . 'month'), GETPOST('dluo' . $suffix . 'day'), GETPOST('dluo' . $suffix . 'year'));
$form->select_date($dluodatesuffix, 'dluo' . $suffix, '', '', 1, "");
print '</td>';
print '<td colspan="2">&nbsp</td>'; // Qty ordered + qty already dispatached
print '<td colspan="3">&nbsp</td>'; // Supplier ref + Qty ordered + qty already dispatched
} else {
$type = 'dispatch';
print '<td align="right">';
@ -650,7 +649,7 @@ if ($id > 0 || ! empty($ref)) {
print '</tr>';
print '<tr class="oddeven" name="' . $type . $suffix . '">';
print '<td colspan="6">';
print '<td colspan="7">';
print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp->rowid . '">';
print '<input name="product' . $suffix . '" type="hidden" value="' . $objp->fk_product . '">';
@ -672,7 +671,7 @@ if ($id > 0 || ! empty($ref)) {
print '<input id="qty' . $suffix . '" name="qty' . $suffix . '" type="text" class="width50 right" value="' . (GETPOST('qty' . $suffix) != '' ? GETPOST('qty' . $suffix) : $remaintodispatch) . '">';
print '</td>';
print '<td>';
print '<td>';
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
$type = 'batch';
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');

View File

@ -45,12 +45,12 @@ class Societe extends CommonObject
* @var string ID to identify managed object
*/
public $element='societe';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'societe';
public $fk_element='fk_soc';
public $fieldsforcombobox='nom,name_alias';
protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object
@ -1348,114 +1348,6 @@ class Societe extends CommonObject
return $result;
}
/**
* Search and fetch thirparties by name
*
* @param string $name Name
* @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier)
* @param array $filters Array of couple field name/value to filter the companies with the same name
* @param boolean $exact Exact string search (true/false)
* @param boolean $case Case sensitive (true/false)
* @param boolean $similar Add test if string inside name into database, or name into database inside string. Do not use this: Not compatible with other database.
* @param string $clause Clause for filters
* @return array|int <0 if KO, array of thirdparties object if OK
*/
function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND')
{
$thirdparties = array();
dol_syslog("searchByName name=".$name." type=".$type." exact=".$exact);
// Check parameter
if (empty($name))
{
$this->errors[]='ErrorBadValueForParameter';
return -1;
}
// Generation requete recherche
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE entity IN (".getEntity('category').")";
if (! empty($type))
{
if ($type == 1 || $type == 2)
$sql.= " AND client = ".$type;
elseif ($type == 3)
$sql.= " AND fournisseur = 1";
}
if (! empty($name))
{
if (! $exact)
{
if (preg_match('/^([\*])?[^*]+([\*])?$/', $name, $regs) && count($regs) > 1)
{
$name = str_replace('*', '%', $name);
}
else
{
$name = '%'.$name.'%';
}
}
$sql.= " AND ";
if (is_array($filters) && ! empty($filters))
$sql.= "(";
if ($similar)
{
// For test similitude (string inside name into database, or name into database inside string)
// Do not use this. Not compatible with other database.
$sql.= "(LOCATE('".$this->db->escape($name)."', nom) > 0 OR LOCATE(nom, '".$this->db->escape($name)."') > 0)";
}
else
{
if (! $case)
$sql.= "nom LIKE '".$this->db->escape($name)."'";
else
$sql.= "nom LIKE BINARY '".$this->db->escape($name)."'";
}
}
if (is_array($filters) && ! empty($filters))
{
foreach($filters as $field => $value)
{
if (! $exact)
{
if (preg_match('/^([\*])?[^*]+([\*])?$/', $value, $regs) && count($regs) > 1)
{
$value = str_replace('*', '%', $value);
}
else
{
$value = '%'.$value.'%';
}
}
if (! $case)
$sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'";
else
$sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'";
}
if (! empty($name))
$sql.= ")";
}
$res = $this->db->query($sql);
if ($res)
{
while ($rec = $this->db->fetch_array($res))
{
$soc = new Societe($this->db);
$soc->fetch($rec['rowid']);
$thirdparties[] = $soc;
}
return $thirdparties;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/**
* Delete a third party from database and all its dependencies (contacts, rib...)
*
@ -1921,10 +1813,10 @@ class Societe extends CommonObject
function add_commercial(User $user, $commid)
{
$error=0;
if ($this->id > 0 && $commid > 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux";
@ -1942,7 +1834,7 @@ class Societe extends CommonObject
}
else {
$this->context=array('commercial_modified'=>$commid);
$result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE',$user);
if ($result < 0) $error++;
}
@ -1960,10 +1852,10 @@ class Societe extends CommonObject
{
$error=0;
$this->context=array('commercial_modified'=>$commid);
$result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE',$user);
if ($result < 0) $error++;
if ($this->id > 0 && $commid > 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux ";