37 lines
2.3 KiB
PHP
37 lines
2.3 KiB
PHP
<?php
|
|
$content = file_get_contents('index.php');
|
|
|
|
$replacements = [
|
|
[
|
|
"case 'sales':\n case 'purchases':\n \$type = (\$page === 'sales') ? 'sale' : 'purchase';\n \$table = (\$type === 'purchase') ? 'purchases' : 'invoices';\n \$cust_supplier_col = (\$type === 'purchase') ? 'supplier_id' : 'customer_id';\n \$cust_supplier_table = (\$type === 'purchase') ? 'suppliers' : 'customers';\n \n \$where = [\"1=1\"];",
|
|
"case 'sales':\n case 'purchases':\n \$type = (\$page === 'sales') ? 'sale' : 'purchase';\n \$table = (\$type === 'purchase') ? 'purchases' : 'invoices';\n \$cust_supplier_col = (\$type === 'purchase') ? 'supplier_id' : 'customer_id';\n \$cust_supplier_table = (\$type === 'purchase') ? 'suppliers' : 'customers';\n \n \$where = [];\n if ((\$_SESSION['outlet_id'] ?? 1) != 0) \$where[] = \"v.outlet_id = \" . (int)(\$_SESSION['outlet_id'] ?? 1);\n else \$where[] = \"1=1\";"
|
|
],
|
|
[
|
|
"case 'quotations':\n \$where = [\"1=1\"];",
|
|
"case 'quotations':\n \$where = [];\n if ((\$_SESSION['outlet_id'] ?? 1) != 0) \$where[] = \"q.outlet_id = \" . (int)(\$_SESSION['outlet_id'] ?? 1);\n else \$where[] = \"1=1\";"
|
|
],
|
|
[
|
|
"case 'lpos':\n \$where = [\"1=1\"];",
|
|
"case 'lpos':\n \$where = [];\n if ((\$_SESSION['outlet_id'] ?? 1) != 0) \$where[] = \"q.outlet_id = \" . (int)(\$_SESSION['outlet_id'] ?? 1);\n else \$where[] = \"1=1\";"
|
|
],
|
|
[
|
|
"case 'expenses':\n \$where = [\"1=1\"];",
|
|
"case 'expenses':\n \$where = [];\n if ((\$_SESSION['outlet_id'] ?? 1) != 0) \$where[] = \"e.outlet_id = \" . (int)(\$_SESSION['outlet_id'] ?? 1);\n else \$where[] = \"1=1\";"
|
|
],
|
|
[
|
|
"case 'payments':",
|
|
"case 'payments':\n \$where = [];\n if ((\$_SESSION['outlet_id'] ?? 1) != 0) \$where[] = \"p.outlet_id = \" . (int)(\$_SESSION['outlet_id'] ?? 1);\n else \$where[] = \"1=1\";"
|
|
]
|
|
];
|
|
|
|
foreach ($replacements as $rep) {
|
|
if (strpos($content, $rep[0]) !== false) {
|
|
$content = str_replace($rep[0], $rep[1], $content);
|
|
echo "Patched successfully\n";
|
|
} else {
|
|
echo "Could not find target to patch\n";
|
|
}
|
|
}
|
|
|
|
file_put_contents('index.php', $content);
|