mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
64 lines
2.8 KiB
PHP
Executable File
64 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Seeder;
|
|
use Streamline\Models\SundryDeposit;
|
|
use Streamline\Models\TreatmentDeposits;
|
|
|
|
class CostPriceSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeders.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$sundry_invoices = \Streamline\Models\PatientCategoryInvoice::where('tag_id', 5)->get();
|
|
$treatment_invoices = \Streamline\Models\PatientCategoryInvoice::where('tag_id', 3)->orWhere('tag_id', 1)->get();
|
|
$sundries = SundryDeposit::get();
|
|
$treatments = TreatmentDeposits::get();
|
|
|
|
foreach ($treatments as $item){
|
|
$cost_price_array = [];
|
|
$items_array = explode(',',$item->treatment_items);
|
|
for ($x = 0; $x < count($items_array); $x++){
|
|
$current_cost_price = get_name($items_array[$x], 'id', 'cost_price', 'drugs');
|
|
array_push($cost_price_array, $current_cost_price);
|
|
}
|
|
$cost_price_string = implode(',',$cost_price_array);
|
|
TreatmentDeposits::where('id', $item->id)->update(['cost_price' => $cost_price_string]);
|
|
}
|
|
foreach ($sundries as $item){
|
|
$cost_price_array = [];
|
|
$items_array = explode(',',$item->sundry_items);
|
|
for ($x = 0; $x < count($items_array); $x++){
|
|
$current_cost_price = get_name($items_array[$x], 'id', 'cost_price', 'sundries');
|
|
array_push($cost_price_array, $current_cost_price);
|
|
}
|
|
$cost_price_string = implode(',',$cost_price_array);
|
|
SundryDeposit::where('id', $item->id)->update(['cost_price' => $cost_price_string]);
|
|
}
|
|
foreach ($treatment_invoices as $item){
|
|
$cost_price_array = [];
|
|
$items_array = explode(',',$item->items_ids);
|
|
for ($x = 0; $x < count($items_array); $x++){
|
|
$current_cost_price = get_latest_inventory_cost_price($items_array[$x], 1, Carbon::today()->toDateString());
|
|
array_push($cost_price_array, $current_cost_price);
|
|
}
|
|
$cost_price_string = implode(',',$cost_price_array);
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $item->id)->update(['cost_price' => $cost_price_string]);
|
|
}
|
|
foreach ($sundry_invoices as $item){
|
|
$cost_price_array = [];
|
|
$items_array = explode(',',$item->items_ids);
|
|
for ($x = 0; $x < count($items_array); $x++){
|
|
$current_cost_price = get_latest_inventory_cost_price($items_array[$x], 2, Carbon::today()->toDateString());
|
|
array_push($cost_price_array, $current_cost_price);
|
|
}
|
|
$cost_price_string = implode(',',$cost_price_array);
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $item->id)->update(['cost_price' => $cost_price_string]);
|
|
}
|
|
}
|
|
}
|