Skip to content

Commit

Permalink
Fix commande/list & facture-rec.class
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Oct 12, 2024
1 parent 307b136 commit fb49c64
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 55 deletions.
4 changes: 2 additions & 2 deletions dev/tools/phan/baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ return [
'htdocs/commande/class/commande.class.php' => ['PhanUndeclaredProperty'],
'htdocs/commande/class/commandestats.class.php' => ['PhanPluginUnknownArrayMethodReturnType'],
'htdocs/commande/customer.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/commande/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/commande/list.php' => ['PhanUndeclaredProperty'],
'htdocs/commande/list_det.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/commande/stats/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/commande/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],
Expand Down Expand Up @@ -162,7 +162,7 @@ return [
'htdocs/compta/facture/card-rec.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/card.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/facture/class/api_invoices.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeComparisonFromArray', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/compta/facture/class/facture-rec.class.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/facture/class/facture.class.php' => ['PhanUndeclaredProperty'],
'htdocs/compta/facture/class/facturestats.class.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType'],
'htdocs/compta/facture/class/paymentterm.class.php' => ['PhanPluginUnknownPropertyType'],
Expand Down
4 changes: 2 additions & 2 deletions htdocs/categories/class/categorie.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,12 +1171,12 @@ protected function load_motherof()
* fullpath = Full path built with the id's
*
* @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...)
* @param int|string|array $fromid Keep only or Exclude (depending on $include parameter) all categories (including the leaf $fromid) into the tree after this id $fromid.
* @param int|string|int[] $fromid Keep only or Exclude (depending on $include parameter) all categories (including the leaf $fromid) into the tree after this id $fromid.
* $fromid can be an :
* - int (id of category)
* - string (categories ids separated by comma)
* - array (list of categories ids)
* @param int $include [=0] Removed or 1=Keep only
* @param int<0,1> $include [=0] Removed or 1=Keep only
* @return int<-1,-1>|array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string,level:?int}> Array of categories. this->cats and this->motherof are set, -1 on error
*/
public function get_full_arbo($type, $fromid = 0, $include = 0)
Expand Down
28 changes: 23 additions & 5 deletions htdocs/commande/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@

if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
$userschilds = $user->getAllChildIds();
} else {
$userschilds = array();
}

// Search Parameters
Expand Down Expand Up @@ -131,6 +133,12 @@
if ($search_option == 'late') {
$search_status = '-2';
}
$search_orderday = '';
$search_ordermonth = '';
$search_orderyear = '';
$search_deliveryday = '';
$search_deliverymonth = '';
$search_deliveryyear = '';

$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id;

Expand Down Expand Up @@ -249,6 +257,12 @@
}

$permissiontoreadallthirdparty = $user->hasRight('societe', 'client', 'voir');
$permissiontoread = false;
$permissiontovalidate = false;
$permissiontoclose = false;
$permissiontocancel = false;
$permissiontosendbymail = false;
$objectclass = null;


$result = restrictedArea($user, 'commande', $id, '');
Expand Down Expand Up @@ -447,6 +461,7 @@

$fk_parent_line = 0;
$num = count($lines);
$array_options = array();

for ($i = 0; $i < $num; $i++) {
$desc = ($lines[$i]->desc ? $lines[$i]->desc : '');
Expand Down Expand Up @@ -732,7 +747,7 @@
}
}
}
if ($action == 'validate' && $permissiontoadd) {
if ($action == 'validate' && $permissiontoadd && $objectclass !== null) {
if (GETPOST('confirm') == 'yes') {
$objecttmp = new $objectclass($db);
$db->begin();
Expand Down Expand Up @@ -768,7 +783,7 @@
}
}
}
if ($action == 'shipped' && $permissiontoadd) {
if ($action == 'shipped' && $permissiontoadd && $objectclass !== null) {
if (GETPOST('confirm') == 'yes') {
$objecttmp = new $objectclass($db);
$db->begin();
Expand Down Expand Up @@ -801,7 +816,7 @@
}

// Closed records
if (!$error && $massaction === 'setbilled' && $permissiontoclose) {
if (!$error && $massaction === 'setbilled' && $permissiontoclose && $objectclass !== null) {
$db->begin();

$objecttmp = new $objectclass($db);
Expand Down Expand Up @@ -1535,7 +1550,7 @@
include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('IncludingProductWithTag');
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 0, array(), 1);
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1);
$moreforfilter .= '</div>';
}
Expand Down Expand Up @@ -2435,7 +2450,7 @@
// Channel
if (!empty($arrayfields['c.fk_input_reason']['checked'])) {
print '<td>';
$form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', '');
$form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', 0);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
Expand Down Expand Up @@ -2710,6 +2725,7 @@
if (!empty($arrayfields['shippable']['checked'])) {
print '<td class="center">';
if (!empty($show_shippable_command) && isModEnabled('stock')) {
$text_icon = '';
if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) {
$generic_commande->getLinesArray(); // Load array ->lines
$generic_commande->loadExpeditions(); // Load array ->expeditions
Expand Down Expand Up @@ -2757,6 +2773,7 @@
$generic_product->load_stats_commande(0, '1,2');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
} else {
// @phan-suppress-next-line PhanTypeInvalidDimOffset
$generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'];
}
$stock_order = $generic_product->stats_commande['qty'];
Expand All @@ -2766,6 +2783,7 @@
$generic_product->load_stats_commande_fournisseur(0, '3');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
} else {
// @phan-suppress-next-line PhanTypeInvalidDimOffset
$generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'];
}
$stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
Expand Down
6 changes: 4 additions & 2 deletions htdocs/compta/facture/card-rec.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice, $fk_parent_line);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, 0, $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice, $fk_parent_line);

if ($result > 0) {
// Define output language and generate document
Expand Down Expand Up @@ -985,6 +985,8 @@
$formother = new FormOther($db);
if (isModEnabled('project')) {
$formproject = new FormProjets($db);
} else {
$formproject = null;
}
$companystatic = new Societe($db);
$invoicerectmp = new FactureRec($db);
Expand Down Expand Up @@ -1101,7 +1103,7 @@
print $object->showOptionals($extrafields, 'create', $parameters);

// Project
if (isModEnabled('project') && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
if (isModEnabled('project') && is_object($object->thirdparty) && $object->thirdparty->id > 0 && is_object($formproject)) {
$projectid = GETPOST('projectid') ? GETPOST('projectid') : $object->fk_project;
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
Expand Down
Loading

0 comments on commit fb49c64

Please sign in to comment.