postpaid always zero for first time recharge and invoice atribute for next month
for postpaid customer invoice reminder and order get from invoice attribute
This commit is contained in:
parent
78d1634470
commit
a15510e62a
@ -246,7 +246,17 @@ class Package
|
|||||||
$t->invoice = "INV-" . Package::_raid();
|
$t->invoice = "INV-" . Package::_raid();
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'] + $add_cost;
|
if ($p['validity_unit'] == 'Period') {
|
||||||
|
// Postpaid price from field
|
||||||
|
$add_inv = User::getAttribute("Invoice", $id_customer);
|
||||||
|
if (empty ($add_inv) or $add_inv == 0) {
|
||||||
|
$t->price = $p['price'] + $add_cost;
|
||||||
|
} else {
|
||||||
|
$t->price = $add_inv + $add_cost;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$t->price = $p['price'] + $add_cost;
|
||||||
|
}
|
||||||
$t->recharged_on = $date_only;
|
$t->recharged_on = $date_only;
|
||||||
$t->recharged_time = $time_only;
|
$t->recharged_time = $time_only;
|
||||||
$t->expiration = $date_exp;
|
$t->expiration = $date_exp;
|
||||||
@ -263,7 +273,7 @@ class Package
|
|||||||
$t->save();
|
$t->save();
|
||||||
|
|
||||||
if ($p['validity_unit'] == 'Period') {
|
if ($p['validity_unit'] == 'Period') {
|
||||||
// insert to fields
|
// insert price to fields for invoice next month
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
||||||
if (!$fl) {
|
if (!$fl) {
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->create();
|
$fl = ORM::for_table('tbl_customers_fields')->create();
|
||||||
@ -319,18 +329,9 @@ class Package
|
|||||||
$t->invoice = "INV-" . Package::_raid();
|
$t->invoice = "INV-" . Package::_raid();
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
if ($p['validity_unit'] == 'Period') {
|
||||||
// Calculating Price
|
// Postpaid price always zero for first time
|
||||||
$sd = new DateTime("$date_only");
|
$t->price = 0 + $add_cost;
|
||||||
$ed = new DateTime("$date_exp");
|
|
||||||
$td = $ed->diff($sd);
|
|
||||||
$fd = $td->format("%a");
|
|
||||||
$gi = ($p['price'] / 30) * $fd;
|
|
||||||
if ($gi > $p['price']) {
|
|
||||||
$t->price = $p['price'] + $add_cost;
|
|
||||||
} else {
|
|
||||||
$t->price = $gi + $add_cost;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$t->price = $p['price'] + $add_cost;
|
$t->price = $p['price'] + $add_cost;
|
||||||
}
|
}
|
||||||
@ -350,12 +351,18 @@ class Package
|
|||||||
$t->save();
|
$t->save();
|
||||||
|
|
||||||
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
||||||
// insert to fields
|
// insert price to fields for invoice next month
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
||||||
if (!$fl) {
|
if (!$fl) {
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->create();
|
$fl = ORM::for_table('tbl_customers_fields')->create();
|
||||||
$fl->customer_id = $c['id'];
|
$fl->customer_id = $c['id'];
|
||||||
$fl->field_name = 'Invoice';
|
$fl->field_name = 'Invoice';
|
||||||
|
// Calculating Price
|
||||||
|
$sd = new DateTime("$date_only");
|
||||||
|
$ed = new DateTime("$date_exp");
|
||||||
|
$td = $ed->diff($sd);
|
||||||
|
$fd = $td->format("%a");
|
||||||
|
$gi = ($p['price'] / 30) * $fd;
|
||||||
if ($gi > $p['price']) {
|
if ($gi > $p['price']) {
|
||||||
$fl->field_value = $p['price'];
|
$fl->field_value = $p['price'];
|
||||||
} else {
|
} else {
|
||||||
@ -433,7 +440,17 @@ class Package
|
|||||||
$t->invoice = "INV-" . Package::_raid();
|
$t->invoice = "INV-" . Package::_raid();
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
$t->price = $p['price'] + $add_cost;
|
if ($p['validity_unit'] == 'Period') {
|
||||||
|
// Postpaid price from field
|
||||||
|
$add_inv = User::getAttribute("Invoice", $id_customer);
|
||||||
|
if (empty ($add_inv) or $add_inv == 0) {
|
||||||
|
$t->price = $p['price'] + $add_cost;
|
||||||
|
} else {
|
||||||
|
$t->price = $add_inv + $add_cost;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$t->price = $p['price'] + $add_cost;
|
||||||
|
}
|
||||||
$t->recharged_on = $date_only;
|
$t->recharged_on = $date_only;
|
||||||
$t->recharged_time = $time_only;
|
$t->recharged_time = $time_only;
|
||||||
$t->expiration = $date_exp;
|
$t->expiration = $date_exp;
|
||||||
@ -450,7 +467,7 @@ class Package
|
|||||||
$t->save();
|
$t->save();
|
||||||
|
|
||||||
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
||||||
// insert to fields
|
// insert price to fields for invoice next month
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
||||||
if (!$fl) {
|
if (!$fl) {
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->create();
|
$fl = ORM::for_table('tbl_customers_fields')->create();
|
||||||
@ -505,18 +522,9 @@ class Package
|
|||||||
$t->invoice = "INV-" . Package::_raid();
|
$t->invoice = "INV-" . Package::_raid();
|
||||||
$t->username = $c['username'];
|
$t->username = $c['username'];
|
||||||
$t->plan_name = $p['name_plan'];
|
$t->plan_name = $p['name_plan'];
|
||||||
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
if ($p['validity_unit'] == 'Period') {
|
||||||
// Calculating Price
|
// Postpaid price always zero for first time
|
||||||
$sd = new DateTime("$date_only");
|
$t->price = 0 + $add_cost;
|
||||||
$ed = new DateTime("$date_exp");
|
|
||||||
$td = $ed->diff($sd);
|
|
||||||
$fd = $td->format("%a");
|
|
||||||
$gi = ($p['price'] / 30) * $fd;
|
|
||||||
if ($gi > $p['price']) {
|
|
||||||
$t->price = $p['price'] + $add_cost;
|
|
||||||
} else {
|
|
||||||
$t->price = $gi + $add_cost;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$t->price = $p['price'] + $add_cost;
|
$t->price = $p['price'] + $add_cost;
|
||||||
}
|
}
|
||||||
@ -536,12 +544,18 @@ class Package
|
|||||||
$t->save();
|
$t->save();
|
||||||
|
|
||||||
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
if ($p['validity_unit'] == 'Period' && $p['price'] != 0) {
|
||||||
// insert to fields
|
// insert price to fields for invoice next month
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
$fl = ORM::for_table('tbl_customers_fields')->where('field_name', 'Invoice')->where('customer_id', $c['id'])->find_one();
|
||||||
if (!$fl) {
|
if (!$fl) {
|
||||||
$fl = ORM::for_table('tbl_customers_fields')->create();
|
$fl = ORM::for_table('tbl_customers_fields')->create();
|
||||||
$fl->customer_id = $c['id'];
|
$fl->customer_id = $c['id'];
|
||||||
$fl->field_name = 'Invoice';
|
$fl->field_name = 'Invoice';
|
||||||
|
// Calculating Price
|
||||||
|
$sd = new DateTime("$date_only");
|
||||||
|
$ed = new DateTime("$date_exp");
|
||||||
|
$td = $ed->diff($sd);
|
||||||
|
$fd = $td->format("%a");
|
||||||
|
$gi = ($p['price'] / 30) * $fd;
|
||||||
if ($gi > $p['price']) {
|
if ($gi > $p['price']) {
|
||||||
$fl->field_value = $p['price'];
|
$fl->field_value = $p['price'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -379,7 +379,18 @@ switch ($action) {
|
|||||||
$d->plan_name = $plan['name_plan'];
|
$d->plan_name = $plan['name_plan'];
|
||||||
$d->routers_id = $router['id'];
|
$d->routers_id = $router['id'];
|
||||||
$d->routers = $router['name'];
|
$d->routers = $router['name'];
|
||||||
$d->price = ($plan['price'] + $add_cost);
|
if ($plan['validity_unit'] == 'Period') {
|
||||||
|
// Postpaid price from field
|
||||||
|
$add_inv = User::getAttribute("Invoice", $id_customer);
|
||||||
|
if (empty ($add_inv) or $add_inv == 0) {
|
||||||
|
$d->price = ($plan['price'] + $add_cost);
|
||||||
|
} else {
|
||||||
|
$d->price = ($add_inv + $add_cost);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$d->price = ($plan['price'] + $add_cost);
|
||||||
|
}
|
||||||
|
//$d->price = ($plan['price'] + $add_cost);
|
||||||
$d->created_date = date('Y-m-d H:i:s');
|
$d->created_date = date('Y-m-d H:i:s');
|
||||||
$d->status = 1;
|
$d->status = 1;
|
||||||
$d->save();
|
$d->save();
|
||||||
@ -391,7 +402,18 @@ switch ($action) {
|
|||||||
$d->plan_name = $plan['name_plan'];
|
$d->plan_name = $plan['name_plan'];
|
||||||
$d->routers_id = $router['id'];
|
$d->routers_id = $router['id'];
|
||||||
$d->routers = $router['name'];
|
$d->routers = $router['name'];
|
||||||
$d->price = ($plan['price'] + $add_cost);
|
if ($plan['validity_unit'] == 'Period') {
|
||||||
|
// Postpaid price from field
|
||||||
|
$add_inv = User::getAttribute("Invoice", $id_customer);
|
||||||
|
if (empty ($add_inv) or $add_inv == 0) {
|
||||||
|
$d->price = ($plan['price'] + $add_cost);
|
||||||
|
} else {
|
||||||
|
$d->price = ($add_inv + $add_cost);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$d->price = ($plan['price'] + $add_cost);
|
||||||
|
}
|
||||||
|
//$d->price = ($plan['price'] + $add_cost);
|
||||||
$d->created_date = date('Y-m-d H:i:s');
|
$d->created_date = date('Y-m-d H:i:s');
|
||||||
$d->status = 1;
|
$d->status = 1;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
@ -38,7 +38,18 @@ foreach ($d as $ds) {
|
|||||||
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
|
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
||||||
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
|
||||||
$price = Lang::moneyFormat($p['price']);
|
if ($p['validity_unit'] == 'Period') {
|
||||||
|
// Postpaid price from field
|
||||||
|
$add_inv = User::getAttribute("Invoice", $ds['customer_id']);
|
||||||
|
if (empty ($add_inv) or $add_inv == 0) {
|
||||||
|
$price = Lang::moneyFormat($p['price']);
|
||||||
|
} else {
|
||||||
|
$price = Lang::moneyFormat($add_inv);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$price = Lang::moneyFormat($p['price']);
|
||||||
|
}
|
||||||
|
//$price = Lang::moneyFormat($p['price']);
|
||||||
if ($ds['expiration'] == $day7) {
|
if ($ds['expiration'] == $day7) {
|
||||||
echo Message::sendPackageNotification($c, $p['name_plan'], $price, Lang::getNotifText('reminder_7_day'), $config['user_notification_reminder']) . "\n";
|
echo Message::sendPackageNotification($c, $p['name_plan'], $price, Lang::getNotifText('reminder_7_day'), $config['user_notification_reminder']) . "\n";
|
||||||
} else if ($ds['expiration'] == $day3) {
|
} else if ($ds['expiration'] == $day3) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user