if ($tariff['0'] != '') { // omit empty tariffs $sql = "INSERT INTO billing_tariffs (prefix_id,cost,initial_cost,trunk_id,tenant_id) VALUES((SELECT id FROM billing_prefixes WHERE pref = '{$tariff['0']}'),'{$tariff['1']}','{$tariff['2']}','{$trunk_id}','{$tenant_id}') ON DUPLICATE KEY UPDATE prefix_id = (SELECT id FROM billing_prefixes WHERE pref = '{$tariff['0']}'),cost = '{$tariff['1']}',initial_cost = '{$tariff['2']}',trunk_id = '{$trunk_id}',tenant_id = '{$tenant_id}'"; echo $sql . "\n"; sql($sql); } } echo "</textarea>"; echo "<br />"; echo _("Data inserted succesfully"); } } else { echo _("There was error uploading file..."); } } elseif ($action == 'delete') { fbilling_del($cat, 'id', $tariff_id); redirect_standard('cat'); } ?> <script> function check_tariff_form() { if (document.forms["tariff_form"]["cost"]) { if (document.forms["tariff_form"]["cost"].value==null || document.forms["tariff_form"]["cost"].value=="") { alert("Please enter valid tariff cost"); return false; } } if (document.forms["tariff_form"]["initial_cost"]) { if (document.forms["tariff_form"]["initial_cost"].value==null || document.forms["tariff_form"]["initial_cost"].value=="") {
$permission_data = fbilling_get_data_by_id($cat, $id); if ($permission_data['name'] == $name) { $insert_ok = 0; } else { $insert_ok = 1; } } if ($insert_ok > 0) { echo _("Permission with specified name already exists in database, please provide different name, and try again"); echo "<a href='javascript:history.go(-1)''> Go Back</a>"; return true; } else { $fields = "name = '{$name}', is_active = {$is_active}"; fbilling_edit($cat, $fields, $id); // update permission details fbilling_del('permission_weights', 'permission_id', $id); // delete all weight relationships for this permission $fields = array('permission_id', 'weight_id'); foreach ($weight_id as $w) { $values[] = array($name, $w); } fbilling_add('permission_weights', $fields, $values); // insert new weight relationships for this permission redirect_standard('cat'); } } ?> <script> function check_permission_form() {
$sql = "INSERT INTO billing_{$cat} (pref,country,description,weight_id,is_active) VALUES ('{$prefix['0']}','{$prefix['1']}','{$prefix['2']}','{$prefix_weight_id}','{$prefix['3']}') ON DUPLICATE KEY UPDATE pref = '{$prefix['0']}',country = '{$prefix['1']}',description = '{$prefix['2']}',weight_id = '{$prefix_weight_id}',is_active = '{$prefix['3']}'"; echo $sql . "\n"; sql($sql); } } echo "</textarea>"; echo "<br />"; echo _("Data inserted succesfully"); } } else { echo _("File not present"); // TODO add goback } } elseif ($action == 'delete') { fbilling_del($cat, 'id', $prefix_id); fbilling_del('tariffs', 'prefix_id', $prefix_id); redirect_standard('cat'); } ?> <script> function check_prefix_form() { if (document.forms["prefix_form"]["prefix"]) { if (document.forms["prefix_form"]["prefix"].value==null || document.forms["prefix_form"]["prefix"].value=="") { alert("Please enter valid tenant prefix"); return false; } } }