3 lines
2.2 KiB
PHP
3 lines
2.2 KiB
PHP
<?php
|
|
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';$path=$s['root'].'/multiline-invoice-backup-pointer.json';if(is_file($path)){echo json_encode(['passed'=>true,'reused_existing_backup'=>true]);exit;}$old=json_decode(file_get_contents(json_decode(file_get_contents($s['root'].'/assets-backup-pointer.json'),true)['root'].'/preservation-private.json'),true);$tables=[];foreach(['host','native']as$n)$tables[$n]=array_keys($old[$n]);$tables['host']=array_unique(array_merge($tables['host'],['fa_meta','fa_versions','fa_commands','si_proposals','si_decisions','si_counters','si_invoices','si_commands','si_events','si_outbox','service_calculation_profiles','service_calculation_results','fr_events','fr_calculations','fr_commands','a_service_drafts','a_billing_drafts','a_history','a_events','a_outbox','a_commands']));$tables['native']=array_unique(array_merge($tables['native'],['gl_asset_books','gl_asset_extension_versions']));$before=[];foreach($tables as$n=>$names){$db=$n==='host'?$host:$native;foreach($names as$t)$before[$n][$t]=$db->table($t)->get()->toJson();}foreach(['binding.json','single-bindings.json','stock-binding.json']as$f)$before['files'][$f]=hash_file('sha256',$s['root'].'/'.$f);file_put_contents($work.'/preservation-private.json',json_encode($before));$files=['app/Modules/Services/ServiceInvoicing.php','app/Modules/Services/ServiceCalculation.php','app/Modules/Services/ServiceFiscal.php','app/Modules/Services/FiscalRules.php','app/Modules/Services/FiscalDocumentMath.php','app/Modules/Services/InvoicePdf.php','app/Modules/Services/DocumentPreview.php','app/Modules/Services/ServiceWorkflow.php','app/Modules/Services/ServiceReceivables.php','app/Modules/Accounting/SalesLedgerSource.php','resources/js/BillingMenuWorkspace.jsx','resources/js/ServiceInvoiceWorkspace.jsx','resources/js/ServicesWorkspace.jsx','routes/web.php'];foreach($files as$f){$to=$work.'/before/'.$f;if(!is_dir(dirname($to)))mkdir(dirname($to),0700,true);copy($s['app'].'/'.$f,$to);}file_put_contents($path,json_encode(['root'=>$work]));echo json_encode(['passed'=>true,'backup'=>$work,'database_writes'=>0,'original_host_sets'=>count($tables['host']),'original_native_sets'=>count($tables['native'])]).PHP_EOL;
|