<?php // Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt /** * edit view form fields section * @author Abhik Chakraborty */ $currency = $_SESSION["do_global_settings"]->get_setting_data_by_name('currency_setting'); $currency_data = json_decode($currency,true); $do_tax = new TaxSettings(); $shipping_handling_tax = $do_tax->shipping_handling_tax(); $product_service_tax = $do_tax->product_service_tax(); ?> <div class="box_content_header"> <?php echo _('Terms and condition'); ?> <hr class="form_hr"> <textarea name="terms_cond" id="terms_cond" class="expand_text_area"><?php echo $module_obj->terms_condition;?></textarea> <br /><br /> <?php if ($module_obj->terms_condition == '') {?> <br /><br /> <span style="font-size:12px;line-height:1.3;"> <input type="checkbox" id="copy_default_terms_cond"> <?php echo _('Copy default terms & condition'); }?> </span> <div style="display:none;"><textarea id="terms_cond_copy"><?php echo $tems_condition;?></textarea></div> <script> $(document.body).on('click', '#copy_default_terms_cond' ,function(e) { if ($(this).is(":checked")) { $("#terms_cond").val($("#terms_cond_copy").val());
/** * function to save the imported vendor * @param object $import_object * @param object $do_crm_fields * @param array $data * @return integer inseted recordid */ public function import_save($import_object, $crm_fields, $data) { $mapped_fields = $import_object->get_mapped_fields(); $table_entity = 'products'; $table_entity_custom = 'products_custom_fld'; $table_entity_to_grp = 'products_to_grp_rel'; $table_products_pricing = 'products_pricing'; $table_products_stock = 'products_stock'; $table_product_tax = 'products_tax'; $entity_data_array = array(); $custom_data_array = array(); $product_stock_data_array = array(); $product_pricing_data_array = array(); $product_tax_data_array = array(); $tax_settings = new TaxSettings(); $product_service_tax = $tax_settings->product_service_tax(); foreach ($crm_fields as $crm_fields) { $field_name = $crm_fields["field_name"]; if ($crm_fields["field_type"] == 165) { foreach ($product_service_tax as $key => $val) { $mapped_field_key = array_search($val["tax_name"], $mapped_fields); if ($mapped_field_key !== false) { $product_tax_data_array[$val["tax_name"]] = $data[$mapped_field_key]; } } } else { $mapped_field_key = array_search($field_name, $mapped_fields); if ($mapped_field_key !== false) { $field_value = $data[$mapped_field_key]; $field_value = $import_object->format_data_before_save($crm_fields["field_type"], $field_value); } else { $field_value = ''; } if ($field_name == 'assigned_to') { $field_name = 'iduser'; $field_value = $_SESSION["do_user"]->iduser; } if ($crm_fields["table_name"] == $table_entity && $crm_fields["idblock"] > 0) { if ($field_name == 'idvendor') { $field_value = $this->map_products_vendor($field_value); } $entity_data_array[$field_name] = $field_value; } elseif ($crm_fields["table_name"] == $table_entity_custom && $crm_fields["idblock"] > 0) { $custom_data_array[$field_name] = $field_value; } elseif ($crm_fields["table_name"] == $table_products_stock && $crm_fields["idblock"] > 0) { $product_stock_data_array[$field_name] = $field_value; } elseif ($crm_fields["table_name"] == $table_products_pricing && $crm_fields["idblock"] > 0) { $product_pricing_data_array[$field_name] = $field_value; } } } //print_r($product_tax_data_array);exit; $this->insert($table_entity, $entity_data_array); $id_entity = $this->getInsertId(); if ($id_entity > 0) { //adding the added_on $q_upd = "\n\t\t\tupdate `" . $this->getTable() . "` \n\t\t\tset `added_on` = ? \n\t\t\twhere `" . $this->primary_key . "` = ?"; $this->query($q_upd, array(date("Y-m-d H:i:s"), $id_entity)); $custom_data_array["idproducts"] = $id_entity; $product_stock_data_array["idproducts"] = $id_entity; $product_pricing_data_array["idproducts"] = $id_entity; $this->insert($table_entity_custom, $custom_data_array); $this->insert($table_products_stock, $product_stock_data_array); $this->insert($table_products_pricing, $product_pricing_data_array); if (is_array($product_tax_data_array) && count($product_tax_data_array) > 0) { foreach ($product_tax_data_array as $tax_name => $tax_value) { $q_ins = "\n\t\t\t\t\tinsert into `{$table_product_tax}` (`idproducts`,`tax_name`,`tax_value`) \n\t\t\t\t\tvalues\n\t\t\t\t\t(?,?,?)\n\t\t\t\t\t"; $this->query($q_ins, array($id_entity, $tax_name, $tax_value)); } } $do_data_history = new DataHistory(); $do_data_history->add_history($id_entity, 12, 'add'); $do_data_history->free(); return $id_entity; } else { return false; } }
continue; } } if ($import_module_id == 5) { if ($do_crmfields->field_name == 'related_to') { $related_to_contact = $do_crmfields->field_label . ' (' . $_SESSION["do_module"]->modules_full_details[4]["name"] . ')'; $related_to_org = $do_crmfields->field_label . ' (' . $_SESSION["do_module"]->modules_full_details[6]["name"] . ')'; $data = array("field_name" => "pot_related_to_contact", "field_label" => $related_to_contact, "field_validation" => $do_crmfields->field_validation); $module_fields["pot_related_to_contact"] = $data; $data = array("field_name" => "pot_related_to_organization", "field_label" => $related_to_org, "field_validation" => $do_crmfields->field_validation); $module_fields["pot_related_to_organization"] = $data; continue; } } if ($do_crmfields->field_type == 165) { $tax_settings = new TaxSettings(); $product_service_tax = $tax_settings->product_service_tax(); if (is_array($product_service_tax) && count($product_service_tax) > 0) { foreach ($product_service_tax as $key => $val) { $module_fields[$val["tax_name"]] = array("field_name" => $val["tax_name"], "field_label" => $val["tax_name"], "field_validation" => ''); } continue; } } $data = array("field_name" => $do_crmfields->field_name, "field_label" => $do_crmfields->field_label, "field_validation" => $do_crmfields->field_validation); $module_fields[$do_crmfields->idfields] = $data; } $row_length = sizeof($mapping_first_row); $_SESSION["do_import"]->set_csv_row_length($row_length); $mandatory_fields = array(); $do_crmfields->get_field_validation_info($import_module_id);
/** * Static function to display form for the field type * @param string $name * @param string $value * @return html for the form containing the field */ public static function display_field($name, $value = '') { $html = ''; $do_tax_settings = new TaxSettings(); if (strlen($value) > 5) { $html .= '<table>'; $i = 1; $tax_settings = $do_tax_settings->product_service_tax(); $tax_setting_names = array(); $tax_setting_values = array(); foreach ($tax_settings as $key => $val) { $tax_setting_names[] = $val["tax_name"]; $tax_setting_values[$val["tax_name"]] = $val["tax_value"]; } $used_tax_values = array(); $tax_name_value_pair = explode(',', $value); foreach ($tax_name_value_pair as $taxes) { $html .= '<tr>'; $tax_values = explode('::', $taxes); $used_tax_values[] = $tax_values[0]; $html .= ' <td style="width:90px;"> <input type="checkbox" name="' . $name . '[]" CHECKED id = "cb_tax_ft_' . $i . '" value="' . $tax_values[0] . '" onclick="show_tax_val_ft(\'' . $i . '\')"><span style="font-size: 12px;margin-left:4px;">' . $tax_values[0] . ' ( % )</span> </td> <td style="margin-left:5px;"><span id="tax_vl_ft_' . $i . '" style="display:block;"><input type="text" value="' . $tax_values[1] . '" class="form-control input-sm" name="' . $name . '_' . $i . '"></td>'; $html .= '</tr>'; $i++; } $diff = array_diff($tax_setting_names, $used_tax_values); foreach ($diff as $t_name => $t_val) { $html .= ' <td style="width:90px;"> <input type="checkbox" name="' . $name . '[]" id ="cb_tax_ft_' . $i . '" value="' . $t_val . '" onclick="show_tax_val_ft(\'' . $i . '\')"><span style="font-size: 12px;margin-left:4px;">' . $t_val . ' ( % )</span> </td> <td style="margin-left:5px;"><span id="tax_vl_ft_' . $i . '" style="display:none;"><input type="text" value="' . $tax_setting_values[$t_val] . '" class="form-control input-sm" name="' . $name . '_' . $i . '"></td>'; $html .= '</tr>'; $i++; } $html .= '</table>'; } else { $qry = "select * from product_service_tax"; $do_tax_settings->query($qry); if ($do_tax_settings->getNumRows() > 0) { $html .= '<table>'; $i = 1; while ($do_tax_settings->next()) { $html .= '<tr>'; $html .= ' <td style="width:90px;"> <input type="checkbox" name="' . $name . '[]" id = "cb_tax_ft_' . $i . '" value="' . $do_tax_settings->tax_name . '" onclick="show_tax_val_ft(\'' . $i . '\')"><span style="font-size: 12px;margin-left:4px;">' . $do_tax_settings->tax_name . ' ( % )</span> </td> <td style="margin-left:5px;"><span id="tax_vl_ft_' . $i . '" style="display:none;"><input type="text" value="' . $do_tax_settings->tax_value . '" class="form-control input-sm" name="' . $name . '_' . $i . '"></span></td>'; $html .= '</tr>'; $i++; } $html .= '</table>'; } } $html .= "\n" . '<script>'; $html .= "\n" . 'function show_tax_val_ft(id){ var span_id = \'tax_vl_ft_\'+id; var check_box_id = \'cb_tax_ft_\'+id; if($("#"+check_box_id).is(\':checked\')){ $("#"+span_id).show(\'slow\'); }else{ $("#"+span_id).hide(\'slow\'); } }'; $html .= '</script>'; echo $html; }
<?php // Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt /** * Currency setting page * @author Abhik Chakraborty */ $do_tax_settings = new TaxSettings(); $product_service_tax = $do_tax_settings->product_service_tax(); $shipping_handling_tax = $do_tax_settings->shipping_handling_tax(); $currency_data = json_decode($currency, true); require_once 'view/tax_settings_view.php';