5 include($path_to_root . "/includes/session.inc");
7 page(_("Company Setup"));
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/ui.inc");
12 include_once($path_to_root . "/admin/db/company_db.inc");
14 //-------------------------------------------------------------------------------------------------
16 if (isset($_POST['submit']) && $_POST['submit'] != "")
21 if (strlen($_POST['coy_name'])==0)
24 display_error(_("The company name must be entered."));
25 set_focus('coy_name');
27 $user_comp = user_company();
28 if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
30 $result = $_FILES['pic']['error'];
31 $filename = $comp_path . "/$user_comp/images";
32 if (!file_exists($filename))
36 $filename .= "/".$_FILES['pic']['name'];
38 //But check for the worst
39 if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG')
41 display_notification(_('Only jpg files are supported - a file extension of .jpg is expected'));
44 elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024))
46 display_notification(_('The file size is over the maximum allowed. The maximum size allowed in KB is') . ' ' . $max_image_size);
49 elseif ( $_FILES['pic']['type'] == "text/plain" )
51 display_notification( _('Only graphics files can be uploaded'));
54 elseif (file_exists($filename))
56 display_notification(_('Attempting to overwrite an existing item image'));
57 $result = unlink($filename);
60 display_error(_('The existing image could not be removed'));
65 if ($input_error != 1)
67 $result = move_uploaded_file($_FILES['pic']['tmp_name'], $filename);
68 $_POST['coy_logo'] = $_FILES['pic']['name'];
69 $message = ($result)?_('File url') ."<a href='$filename'>$filename</a>" : "Somthing is wrong with uploading a file.";
71 /* EOF Add Image upload for New Item - by Ori */
74 if ($input_error != 1)
76 update_company_setup($_POST['coy_name'], $_POST['coy_no'], $_POST['gst_no'], $_POST['tax_prd'], $_POST['tax_last'],
77 $_POST['postal_address'], $_POST['phone'], $_POST['fax'], $_POST['email'], $_POST['coy_logo'], $_POST['domicile'],
78 $_POST['use_dimension'], $_POST['custom1_name'], $_POST['custom2_name'], $_POST['custom3_name'],
79 $_POST['custom1_value'], $_POST['custom2_value'], $_POST['custom3_value'],
80 $_POST['curr_default'], $_POST['f_year'], check_value('no_item_list'), check_value('no_customer_list'),
81 check_value('no_supplier_list'), $_POST['base_sales']);
83 display_notification_centered(_("Company setup has been updated."));
86 } /* end of if submit */
88 //---------------------------------------------------------------------------------------------
93 $myrow = get_company_prefs();
95 $_POST['coy_name'] = $myrow["coy_name"];
96 $_POST['gst_no'] = $myrow["gst_no"];
97 $_POST['tax_prd'] = $myrow["tax_prd"];
98 $_POST['tax_last'] = $myrow["tax_last"];
99 $_POST['coy_no'] = $myrow["coy_no"];
100 $_POST['postal_address'] = $myrow["postal_address"];
101 $_POST['phone'] = $myrow["phone"];
102 $_POST['fax'] = $myrow["fax"];
103 $_POST['email'] = $myrow["email"];
104 $_POST['coy_logo'] = $myrow["coy_logo"];
105 $_POST['domicile'] = $myrow["domicile"];
106 $_POST['use_dimension'] = $myrow["use_dimension"];
107 $_POST['base_sales'] = $myrow["base_sales"];
108 $_POST['no_item_list'] = $myrow["no_item_list"];
109 $_POST['no_customer_list'] = $myrow["no_customer_list"];
110 $_POST['no_supplier_list'] = $myrow["no_supplier_list"];
111 $_POST['custom1_name'] = $myrow["custom1_name"];
112 $_POST['custom2_name'] = $myrow["custom2_name"];
113 $_POST['custom3_name'] = $myrow["custom3_name"];
114 $_POST['custom1_value'] = $myrow["custom1_value"];
115 $_POST['custom2_value'] = $myrow["custom2_value"];
116 $_POST['custom3_value'] = $myrow["custom3_value"];
117 $_POST['curr_default'] = $myrow["curr_default"];
118 $_POST['f_year'] = $myrow["f_year"];
120 start_table($table_style2);
122 text_row_ex(_("Name (to appear on reports):"), 'coy_name', 42, 50);
123 text_row_ex(_("Official Company Number:"), 'coy_no', 25);
124 text_row_ex(_("Tax Authority Reference:"), 'gst_no', 25);
126 text_row_ex(_("Tax Periods:"), 'tax_prd', 10, 10, '', null, null, _('Months.'));
127 text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.'));
129 currencies_list_row(_("Home Currency:"), 'curr_default', $_POST['curr_default']);
130 fiscalyears_list_row(_("Fiscal Year:"), 'f_year', $_POST['f_year']);
132 textarea_row(_("Address:"), 'postal_address', $_POST['postal_address'], 35, 5);
134 text_row_ex(_("Telephone Number:"), 'phone', 25, 55);
135 text_row_ex(_("Facsimile Number:"), 'fax', 25);
136 text_row_ex(_("Email Address:"), 'email', 25, 55);
137 label_row(_("Company Logo:"), $_POST['coy_logo']);
138 label_row(_("New")." "._("Company Logo (.jpg)") . ":", "<input type='file' id='pic' name='pic'>");
140 text_row_ex(_("Domicile:"), 'domicile', 25, 55);
142 number_list_row(_("Use Dimensions:"), 'use_dimension', null, 0, 2);
143 sales_types_list_row(_("Base for auto price calculations:"), 'base_sales', $_POST['base_sales'], false,
144 _('No base price list') );
146 check_row(_("Search Item List"), 'no_item_list', $_POST['no_item_list']);
147 check_row(_("Search Customer List"), 'no_customer_list', $_POST['no_customer_list']);
148 check_row(_("Search Supplier List"), 'no_supplier_list', $_POST['no_supplier_list']);
152 label_row(_("Custom Field Name"), _("Custom Field Value"));
155 text_cells(null, 'custom1_name', $_POST['custom1_name'], 25, 25);
156 text_cells(null, 'custom1_value', $_POST['custom1_value'], 30, 30);
160 text_cells(null, 'custom2_name', $_POST['custom2_name'], 25, 25);
161 text_cells(null, 'custom2_value', $_POST['custom2_value'], 30, 30);
165 text_cells(null, 'custom3_name', $_POST['custom3_name'], 25, 25);
166 text_cells(null, 'custom3_value', $_POST['custom3_value'], 30, 30);
170 hidden('coy_logo', $_POST['coy_logo']);
171 submit_center('submit', _("Update"));
174 //-------------------------------------------------------------------------------------------------