| ';
print $langs->trans("SupplierOrder").' | ';
print '';
@@ -2477,26 +2476,25 @@ if ($action == 'create' && $permissiontoadd) {
// Get list of products already sent for same source object into $alreadysent
$alreadysent = array();
- //$origin = 'commande_fournisseur';
+ if (empty($origin)) {
+ $origin = 'supplier_order';
+ }
- if ($origin && $origin_id > 0) {
+ if ($origin_id > 0) {
$sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
$sql .= ", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot";
$sql .= ", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception";
- //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received";
$sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch';
$sql .= ', p.description as product_desc';
$sql .= " FROM ".MAIN_DB_PREFIX."receptiondet_batch as ed";
$sql .= ", ".MAIN_DB_PREFIX."reception as e";
- $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj";
- //if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line";
+ $sql .= ", ".MAIN_DB_PREFIX.(($origin == 'supplier_order') ? 'commande_fournisseur' : $origin)."det as obj";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
$sql .= " WHERE e.entity IN (".getEntity('reception').")";
$sql .= " AND obj.fk_commande = ".((int) $origin_id);
$sql .= " AND obj.rowid = ed.fk_elementdet";
$sql .= " AND ed.fk_reception = e.rowid";
$sql .= " AND ed.fk_reception !=".((int) $object->id);
- //if ($filter) $sql.= $filter;
$sql .= " ORDER BY obj.fk_product";
dol_syslog("get list of reception lines", LOG_DEBUG);
diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php
index 0ead07ec0d0..a6cdddd9c0e 100644
--- a/htdocs/reception/class/reception.class.php
+++ b/htdocs/reception/class/reception.class.php
@@ -336,7 +336,7 @@ class Reception extends CommonObject
$sql .= ", fk_incoterms, location_incoterms";
$sql .= ") VALUES (";
$sql .= "'(PROV)'";
- $sql .= ", ".((int) $conf->entity);
+ $sql .= ", ".((int) $this->entity);
$sql .= ", ".($this->ref_supplier ? "'".$this->db->escape($this->ref_supplier)."'" : "null");
$sql .= ", '".$this->db->idate($this->date_creation)."'";
$sql .= ", ".((int) $user->id);
@@ -746,7 +746,7 @@ class Reception extends CommonObject
}
}
- if (!$error) {
+ if (!$error && $this->origin_id > 0) {
// Change status of purchase order to "reception in process" or "totally received"
$status = $this->getStatusDispatch();
if ($status < 0) {
diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php
index e901cde50c8..f1bb7e61a6b 100644
--- a/htdocs/reception/dispatch.php
+++ b/htdocs/reception/dispatch.php
@@ -322,7 +322,6 @@ llxHeader('', $title, $help_url, '', 0, 0, $morejs, '', '', 'mod-reception page-
if ($id > 0 || !empty($ref)) {
$typeobject = '';
if (!empty($object->origin) && $object->origin_id > 0) {
- $object->origin = 'CommandeFournisseur';
$typeobject = $object->origin;
$origin = $object->origin;
$origin_id = $object->origin_id;
@@ -418,7 +417,7 @@ if ($id > 0 || !empty($ref)) {
print " | \n";
print '
';
}
- if ($typeobject == 'CommandeFournisseur' && $object->origin_object->id && isModEnabled("propal")) {
+ if (($typeobject == 'supplier_order' || $typeobject == 'order_supplier') && $object->origin_object->id && isModEnabled("propal")) {
print '