static function getAll(&$PDOdb, $type = 'AMOUNT', $asArray = false, $with_zip = false, $with_fk_shipment_mode = false) { $TRemise = array(); $sql = "SELECT rowid,palier,remise,zip,fk_shipment_mode\n\t\tFROM " . MAIN_DB_PREFIX . "remise WHERE type='" . $type . "' \n\t\t"; if ($type == 'AMOUNT') { $sql .= "ORDER BY palier DESC,zip DESC ,fk_shipment_mode DESC"; } else { $sql .= "ORDER BY palier DESC, zip DESC, fk_shipment_mode DESC"; } $Tab = $PDOdb->ExecuteAsArray($sql); $last_palier = 0; foreach ($Tab as &$row) { if ($asArray) { $row->last_palier = $last_palier; $o = (array) $row; if ($last_palier < $row->palier) { $last_palier = $row->palier; } } else { $o = new TRemise(); $o->load($PDOdb, $row->rowid); } $TRemise[] = $o; } return $TRemise; }
dol_include_once('/remise/class/remise.class.php'); $langs->load("admin"); $langs->load("deliveries"); $type = GETPOST('type'); if (empty($type)) { $type = 'AMOUNT'; } $action = GETPOST('action'); $remise = new TRemise(); $PDOdb = new TPDOdb(); switch ($action) { case 'save': if (GETPOST('bt_cancel') != '') { header('location:' . dol_buildpath('/remise/admin/remise.php?type=' . GETPOST('type'), 1)); } else { $remise->load($PDOdb, GETPOST('id')); $remise->set_values($_POST); $remise->save($PDOdb); setEventMessage($langs->trans('RemiseSaved')); header('location:' . dol_buildpath('/remise/admin/remise.php?type=' . GETPOST('type') . '&TListTBS[lPrice][orderBy][date_maj]=DESC', 1)); } case 'edit': $remise->load($PDOdb, GETPOST('id')); fiche($remise, $type, 'edit'); break; case 'new': fiche($remise, $type, 'edit'); break; default: liste($type); break;