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

This commit is contained in:
Laurent Destailleur 2018-01-11 00:56:01 +01:00
commit e9bf6ed4ce
10 changed files with 113 additions and 24 deletions

View File

@ -785,7 +785,8 @@ if ($resql)
Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
Facture::TYPE_SITUATION=>$langs->trans("InvoiceSituation"),
);
//$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order.
print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100');

View File

@ -1114,5 +1114,31 @@ class Paiement extends CommonObject
}*/
return '';
}
/**
* Load the third party of object, from id into this->thirdparty
*
* @param int $force_thirdparty_id Force thirdparty id
* @return int <0 if KO, >0 if OK
*/
function fetch_thirdparty($force_thirdparty_id=0)
{
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
if (empty($force_thirdparty_id))
{
$billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first invoice to get him
if (!empty($billsarray))
{
$supplier_invoice = new FactureFournisseur($this->db);
if ($supplier_invoice->fetch($billsarray[0]) > 0)
{
$force_thirdparty_id = $supplier_invoice->fk_soc;
}
}
}
return parent::fetch_thirdparty($force_thirdparty_id);
}
}

View File

@ -58,9 +58,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'ro
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) {
$page = 0;
}
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -108,7 +106,7 @@ if ($object->id)
}
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
{
@ -120,11 +118,11 @@ if ($object->id)
else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany");
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
@ -147,7 +145,7 @@ if ($object->id)
print '</td></tr>';
}
}*/
// Civility
print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $object->getCivilityLabel();
@ -160,7 +158,7 @@ if ($object->id)
print '</div>';
dol_fiche_end();
$modulepart = 'contact';
$permission = $user->rights->societe->contact->creer;
$permtoedit = $user->rights->societe->contact->creer;

View File

@ -477,3 +477,42 @@ function measuring_units_string($unit,$measuring_style='')
return $measuring_units[$unit];
}
/**
* Transform a given unit into the square of that unit, if known
*
* @param int $unit Unit key (-3,-2,-1,0,98,99...)
* @return int Squared unit key (-6,-4,-2,0,98,99...)
* @see formproduct->load_measuring_units
*/
function measuring_units_squared($unit)
{
$measuring_units=array();
$measuring_units[0] = 0; // m -> m3
$measuring_units[-1] = -2; // dm-> dm2
$measuring_units[-2] = -4; // cm -> cm2
$measuring_units[-3] = -6; // mm -> mm2
$measuring_units[98] = 98; // foot -> foot2
$measuring_units[99] = 99; // inch -> inch2
return $measuring_units[$unit];
}
/**
* Transform a given unit into the cube of that unit, if known
*
* @param int $unit Unit key (-3,-2,-1,0,98,99...)
* @return int Cubed unit key (-9,-6,-3,0,88,89...)
* @see formproduct->load_measuring_units
*/
function measuring_units_cubed($unit)
{
$measuring_units=array();
$measuring_units[0] = 0; // m -> m2
$measuring_units[-1] = -3; // dm-> dm3
$measuring_units[-2] = -6; // cm -> cm3
$measuring_units[-3] = -9; // mm -> mm3
$measuring_units[98] = 88; // foot -> foot3
$measuring_units[99] = 89; // inch -> inch3
return $measuring_units[$unit];
}

View File

@ -723,12 +723,12 @@ class pdf_standard extends ModelePDFSuppliersPayments
if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $mysoc;
$thirdparty = $object->thirdparty;
}
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
// Show recipient
$widthrecbox=90;

View File

@ -734,4 +734,30 @@ class PaiementFourn extends Paiement
return $way;
}
/**
* Load the third party of object, from id into this->thirdparty
*
* @param int $force_thirdparty_id Force thirdparty id
* @return int <0 if KO, >0 if OK
*/
function fetch_thirdparty($force_thirdparty_id=0)
{
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
if (empty($force_thirdparty_id))
{
$billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him
if (!empty($billsarray))
{
$supplier_invoice = new FactureFournisseur($this->db);
if ($supplier_invoice->fetch($billsarray[0]) > 0)
{
$force_thirdparty_id = $supplier_invoice->fk_soc;
}
}
}
return parent::fetch_thirdparty($force_thirdparty_id);
}
}

View File

@ -171,16 +171,15 @@ if (($action == 'create' || $action == 'add') && ! $error) {
if ($ret < 0) $error++;
if ($_POST['origin'] && $_POST['originid']) {
$object->linked_objects = $orders_id;
$linked_orders_ids=array();
foreach ( $orders_id as $origin => $origin_id ) {
$origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]);
$linked_orders_ids[]=$origin_id;
}
$object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids);
$id = $object->create($user);
if ($id > 0) {
foreach ( $orders_id as $origin => $origin_id ) {
$origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]);
$object->add_object_linked(GETPOST('origin'), $origin_id);
}
while ( $ii < $nn ) {
$objectsrc = new CommandeFournisseur($db);
dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");

View File

@ -73,7 +73,7 @@ if ($action == 'convert')
{
$vat_src_code_old = $reg[1];
$oldvatrateclean = preg_replace('/\s*\(.*\)/', '', $oldvatrate); // Remove code into vatrate.
}
} else $oldvatrateclean=$oldvatrate;
// Clean vat code new
$vat_src_code_new='';
@ -81,7 +81,7 @@ if ($action == 'convert')
{
$vat_src_code_new = $reg[1];
$newvatrateclean = preg_replace('/\s*\(.*\)/', '', $newvatrate); // Remove code into vatrate.
}
} else $newvatrateclean=$newvatrate;
// If country to edit is my country, so we change customer prices
if ($country_id == $mysoc->country_id)

View File

@ -745,12 +745,12 @@ class Product extends CommonObject
if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units)
{
$this->surface = $this->length * $this->width;
$this->surface_units = $this->length_units + $this->width_units;
$this->surface_units = measuring_units_squared($this->length_units);
}
if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units)
{
$this->volume = $this->surface * $this->height;
$this->volume_units = $this->surface_units + $this->height_units;
$this->volume_units = measuring_units_cubed($this->height_units);
}
$this->surface = price2num($this->surface);

View File

@ -821,7 +821,7 @@ else
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
{
$htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1);
print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext);
print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext);
}
else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT");
}