Commit bcbd2379 authored by Karamel's avatar Karamel
Browse files

Fix v7 db import with inexistent DISCOUNTS and fix customers import.

parent f366dd17
......@@ -4,7 +4,7 @@
namespace Pasteque\bin;
use Pasteque\Server\AppContext;
use \Pasteque\Server\AppContext;
if ($argc < 3) {
die("importdb.php <v7 user id> <v8 user id>\n"
......@@ -90,7 +90,12 @@ function readBin($val, $dbType) {
return $data;
}
}
function readDate($val) {
if ($val === null) { return null; }
$dateTime = \DateTime::createFromFormat('Y-m-d H:i:s', $val);
if(!$dateTime) { return false; }
return $dateTime;
}
$imgApi = \Pasteque\Server\API\ImageAPI::fromApp($ptApp);
......@@ -257,7 +262,10 @@ if ($stmt->execute()) {
}
} else {
$err = $stmt->errorInfo();
die('DISCOUNTS error' . $err[2]);
// Table DISCUNTS may not exists. Not a big deal.
// It was created on 6.0 but not included in upgrade scripts.
// Nobody uses it probably.
echo('DISCOUNTS error ' . $err[2] . "\n");
}
// PaymentModes, PaymentModeReturns and PaymentModeValues
......@@ -486,27 +494,27 @@ if ($stmt->execute()) {
$customer = new \Pasteque\Server\Model\Customer();
$customer->setDispName($row['NAME']);
if (!empty($row['CARD'])) {
$customer->setCard($row['CARD']);
$customer->setCard(($row['CARD']===null)?'':$row['CARD']);
}
$customer->setMaxDebt($row['MAXDEBT']);
$customer->setCurrDebt($row['CURDEBT']);
$customer->setCurrDebt(($row['CURDEBT']===null)?0.0:$row['CURDEBT']);
$customer->setDebtDate($row['CURDATE']);
$customer->setPrepaid($row['PREPAID']);
$customer->setFirstName($row['FIRSTNAME']);
$customer->setLastName($row['LASTNAME']);
$customer->setEmail($row['EMAIL']);
$customer->setPhone1($row['PHONE']);
$customer->setPhone2($row['PHONE2']);
$customer->setFax($row['FAX']);
$customer->setAddr1($row['ADDRESS']);
$customer->setAddr2($row['ADDRESS2']);
$customer->setZipCode($row['POSTAL']);
$customer->setCity($row['CITY']);
$customer->setRegion($row['REGION']);
$customer->setCountry($row['COUNTRY']);
$customer->setNote($row['NOTES']);
$customer->setFirstName(($row['FIRSTNAME']===null)?'':$row['FIRSTNAME']);
$customer->setLastName(($row['LASTNAME']===null)?'':$row['LASTNAME']);
$customer->setEmail(($row['EMAIL']===null)?'':$row['EMAIL']);
$customer->setPhone1(($row['PHONE']===null)?'':$row['PHONE']);
$customer->setPhone2(($row['PHONE2']===null)?'':$row['PHONE2']);
$customer->setFax(($row['FAX']===null)?'':$row['FAX']);
$customer->setAddr1(($row['ADDRESS']===null)?'':$row['ADDRESS']);
$customer->setAddr2(($row['ADDRESS2']===null)?'':$row['ADDRESS2']);
$customer->setZipCode(($row['POSTAL']===null)?'':$row['POSTAL']);
$customer->setCity(($row['CITY']===null)?'':$row['CITY']);
$customer->setRegion(($row['REGION']===null)?'':$row['REGION']);
$customer->setCountry(($row['COUNTRY']===null)?'':$row['COUNTRY']);
$customer->setNote(($row['NOTES']===null)?'':$row['NOTES']);
$customer->setVisible(readBool($row['VISIBLE']));
$customer->setExpireDate($row['EXPIREDATE']);
$customer->setExpireDate(readDate($row['EXPIREDATE']));
if (!empty($row['DISCOUNTPROFILE_ID'])) {
$customer->setDiscountProfile($discountProfileMapping[$row['DISCOUNTPROFILE_ID']]);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment