// // You should have received a copy of the GNU General Public License // along with Pastèque. If not, see <http://www.gnu.org/licenses/>. namespace BaseStocks; $message = null; $error = null; $modules = \Pasteque\get_loaded_modules(\Pasteque\get_user_id()); $multilocations = false; $locSrv = new \Pasteque\LocationsService(); $locations = $locSrv->getAll(); $defaultLocationId = $locations[0]->id; if (in_array("stock_multilocations", $modules)) { $multilocations = true; } $dateStr = isset($_POST['date']) ? $_POST['date'] : \i18nDate(time()); $time = \i18nRevDate($dateStr); if (isset($_POST['reason']) && !isset($_POST['sendCsv'])) { $reason = $_POST['reason']; if ($multilocations) { $locationId = $_POST['location']; } else { $locationId = $defaultLocationId; } foreach ($_POST as $key => $value) { if (strpos($key, "qty-") === 0) { $productId = substr($key, 4); $product = \Pasteque\ProductsService::get($productId); switch ($reason) { case \Pasteque\StockMove::REASON_OUT_SELL: case \Pasteque\StockMove::REASON_IN_REFUND:
} } $cust = null; $currDebt = ""; $prepaid = 0; $str_debtDate = ""; $str_expireDate = ""; if (isset($_GET['id'])) { $cust = \Pasteque\CustomersService::get($_GET['id']); $currDebt = $cust->currDebt; $prepaid = $cust->prepaid; if ($cust->debtDate !== NULL) { $str_debtDate = \i18nDateTime($cust->debtDate); } if ($cust->expireDate !== NULL) { $str_expireDate = \i18nDate($cust->expireDate); } } ?> <h1><?php \pi18n("Edit a customer", PLUGIN_NAME); ?> </h1> <?php \Pasteque\tpl_msg_box($message, $error); ?> <?php if ($cust !== null) { ?>
function form_input($form_id, $class, $object, $field, $type, $args = array()) { if (!isset($args['nolabel']) || $args['nolabel'] === false) { echo "<div class=\"row\">\n"; } if (isset($args['nameid']) && $args['nameid'] == true) { $name = $field . "-" . $form_id; } else { $name = $field; } if (isset($args['array']) && $args['array'] == true) { $name = $name . "[]"; } if ($type != "pick_multiple") { if (!isset($args['nolabel']) || $args['nolabel'] === false) { echo '<label for="' . esc_attr($form_id . '-' . $field) . '">'; $fieldLabel = $field; if (substr($field, -2) == "Id") { $fieldLabel = substr($field, 0, -2); } echo esc_html(\i18n($class . "." . $fieldLabel)); echo "</label>\n"; } } $required = ""; if (isset($args['required']) && $args['required']) { $required = ' required="true"'; } switch ($type) { case 'string': echo '<input id="' . esc_attr($form_id . '-' . $field) . '" type="text" name="' . esc_attr($name) . '"'; if ($object != NULL) { echo ' value="' . esc_attr($object->{$field}) . '"'; } echo "{$required} />\n"; break; case 'text': echo '<textarea id="' . esc_attr($form_id . '-' . $field) . '" name="' . esc_attr($name) . '">'; if ($object != NULL) { echo esc_html($object->{$field}); } echo '</textarea>'; break; case 'numeric': echo '<input id="' . esc_attr($form_id . '-' . $field) . '" type="numeric" name="' . esc_attr($name) . '"'; if ($object != NULL) { echo ' value="' . esc_attr($object->{$field}) . '"'; } echo "{$required} />\n"; break; case 'boolean': echo '<input id="' . esc_attr($form_id . '-' . $field) . '" type="checkbox" name="' . esc_attr($name) . '"'; if ($object != NULL) { if ($object->{$field}) { echo ' checked="checked"'; } } else { if (!isset($args['default']) || $args['default'] == TRUE) { echo ' checked="checked"'; } } echo " />\n"; break; case 'float': if (!isset($args['step'])) { $step = 0.01; } else { $step = $args['step']; } echo '<input id="' . esc_attr($form_id . '-' . $field) . '" type="number" step="' . esc_attr($step) . '" min="0.00" name="' . esc_attr($name) . '"'; if ($object != NULL) { echo ' value="' . esc_attr($object->{$field}) . '"'; } echo "{$required} />\n"; break; case 'date': // Class dateinput will be catched to show js date picker echo '<input id="' . esc_attr($form_id . '-' . $field) . '" type="text" class="dateinput" name="' . esc_attr($name) . '"'; if ($object !== null) { if (isset($args['dataformat'])) { if ($args['dataformat'] == 'standard') { $timestamp = stdtimefstr($object->{$field}); } else { $timestamp = timefstr($args['dataformat'], $object->{$field}); } } else { $timestamp = $object->{$field}; } echo ' value="' . esc_attr(\i18nDate($timestamp)) . '"'; } echo "{$required} />\n"; break; case 'pick': $model = $args['model']; $data = $args['data']; if ($model !== null) { switch ($model) { case 'Category': $data = CategoriesService::getAll(false); break; case 'Provider': $data = ProvidersService::getAll(); break; case 'TaxCategory': $data = TaxesService::getAll(); break; case 'Tax': $cats = TaxesService::getAll(); $data = array(); foreach ($cats as $cat) { $data[] = $cat->getCurrentTax(); } break; case 'CustTaxCat': $data = CustTaxCatsService::getAll(); break; case 'Role': $data = RolesService::getAll(); break; case 'Attribute': $data = AttributesService::getAllAttrs(); break; case 'AttributeSet': $data = AttributesService::getAll(); break; case 'Location': $locSrv = new LocationsService(); $data = $locSrv->getAll(); break; case 'DiscountProfile': $profSrv = new DiscountProfilesService(); $data = $profSrv->getAll(); break; case 'TariffArea': $areaSrv = new TariffAreasService(); $data = $areaSrv->getAll(); break; } } echo '<select id="' . esc_attr($form_id . '-' . $field) . '" name="' . esc_attr($name) . '">'; if (isset($args['nullable']) && $args['nullable']) { echo '<option value=""></option>'; } foreach ($data as $r) { $selected = ""; $r_id = $r->id; $r_label = $r->label; if ($model == null) { $r_id = $r['id']; $r_label = $r['label']; } if ($object != NULL && ($object->{$field} == $r_id || is_object($object->{$field}) && $object->{$field}->id == $r_id)) { $selected = ' selected="true"'; } echo '<option value="' . esc_attr($r_id) . '"' . $selected . '>' . esc_html($r_label) . '</option>'; } echo "</select>\n"; break; case 'pick_multiple': $model = $args['model']; switch ($model) { case 'Category': $data = CategoriesService::getAll(); break; } foreach ($data as $r) { $selected = ""; if ($object != NULL && array_search($r->id, $object->{$field}) !== FALSE) { $selected = ' checked="true"'; } $id = $form_id . "-" . $field . "-" . $r->id; echo '<label for="' . esc_attr($id) . '">' . esc_html($r->label) . '</label>'; echo '<input id="' . esc_attr($id) . '" type="checkbox" name="' . esc_attr($name) . '[]" value="' . esc_attr($r->id) . '"' . $selected . "/>\n"; } break; } if (!isset($args['nolabel']) || $args['nolabel'] === false) { echo "</div>"; } }
function __tpl_report_input($report, $values) { // Export button echo "<div id=\"btn\"><a class=\"btn\" href=\"" . \Pasteque\get_report_url($report->getDomain(), $report->getId()); foreach ($report->getParams() as $param) { echo "&" . $param['param'] . "=" . $values[$param['param']]; } echo "\">" . \i18n("Export") . "</a></div>\n"; echo "<br />\n"; if (is_array($report->getParams()) && sizeof($report->getParams()) > 0) { // Input form echo "<form class=\"edit\" action=\"" . \Pasteque\get_current_url() . "\" " . "method=\"post\">"; foreach ($report->getParams() as $param) { $id = $param['param']; echo "<div class=\"row\">"; if ($param['label'] != null && $param['label'] != "" && $param['type'] != "hidden") { echo "<label for=\"" . $id . "\">" . $param['label'] . "</label>"; } switch ($param['type']) { case DB::DATE: $value = \i18nDate($values[$id]); echo "<input type=\"text\" name=\"" . $id . "\" id=\"" . $id . "\" class=\"dateinput\" value=\"" . $value . "\" />"; break; case 'hidden': $value = $values[$param['param']]; echo "<input type=\"hidden\" name=\"" . $id . "\" id=\"" . $id . "\" value=\"" . $value . "\" />"; break; default: $value = $values[$param['param']]; echo "<input type=\"text\" name=\"" . $id . "\" id=\"" . $id . "\" value=\"" . $value . "\" />"; break; } echo "</div>\n"; } // Send echo "<div class=\"row actions\">" . \Pasteque\form_send() . "</div>\n"; echo "</form>\n"; } }
function __tpl_report_input($report, $values) { echo "<div class=\"col-md-12 panel-group\" id=\"options\"" . " role=\"tablist\" aria-multiselectable=\"true\">\n"; // Export button echo "\t<div><a class=\"btn btn-primary\" href=\"" . \Pasteque\get_report_url($report->getDomain(), $report->getId()); foreach ($report->getParams() as $param) { echo "&" . $param['param'] . "=" . $values[$param['param']]; } echo "\">" . \i18n("Export") . "</a></div>\n"; // Collapsable options echo "\t<div class=\"panel panel-default\">\n"; echo "\t\t<div class=\"panel-heading\" role=\"tab\" id=\"options-heading\">\n"; echo "\t\t\t<h4 class=\"panel-title\">" . "<a role=\"button\" data-toggle=\"collapse\"" . " data-parent=\"#options\" href=\"#options-collapsed\"" . " aria-expanded=\"false\" aria-controls=\"options-collapsed\">" . "Options</a></h4>\n"; echo "\t\t</div>\n"; echo "\t\t<div id=\"options-collapsed\" class=\"panel-collapse collapse\"" . " role=\"tabpanel\" aria-labelledby=\"options-heading\">\n"; echo "\t\t\t<div class=\"panel-body\">\n"; if (is_array($report->getParams()) && sizeof($report->getParams()) > 0) { // Input form echo "\t\t\t<div class=\"col-md-4\">\n"; echo "\t\t\t\t\t<form class=\"edit\" action=\"" . \Pasteque\get_current_url() . "\" " . "method=\"post\">\n"; foreach ($report->getParams() as $param) { $id = $param['param']; switch ($param['type']) { case DB::DATE: if ($param['label'] != null && $param['label'] != "" && $param['type'] != "hidden") { echo "\t\t\t\t\t\t<label for=\"" . $id . "\">" . $param['label'] . "</label>\n"; } $value = \i18nDate($values[$id]); echo "\t\t\t\t\t\t<div data-date-format=\"yyyy-mm-dd\" class=\"input-group date col-md-6\" id=\"datepicker-" . $id . "\">\n"; echo "\t\t\t\t\t\t\t<input type=\"text\"" . " class=\"form-control\" name=\"" . $id . "\" id=\"" . $id . "\" value=\"" . $value . "\">\n"; echo "\t\t\t\t\t\t\t<div class=\"input-group-addon\">\n"; echo "\t\t\t\t\t\t\t\t<span class=\"glyphicon glyphicon-th\"></span>\n"; echo "\t\t\t\t\t\t\t</div>\n"; echo "\t\t\t\t\t\t</div>\n"; break; case 'hidden': $value = $values[$param['param']]; echo "\t\t\t<input type=\"hidden\" name=\"" . $id . "\" id=\"" . $id . "\" value=\"" . $value . "\" />"; break; default: $value = $values[$param['param']]; echo "\t\t\t<input type=\"text\" name=\"" . $id . "\" id=\"" . $id . "\" value=\"" . $value . "\" />"; break; } } // Send echo "\t\t\t\t\t\t<div class=\"row actions\">" . \Pasteque\form_send() . "</div>\n"; echo "\t\t\t\t\t</form>\n"; echo "\t\t\t\t</div>\n"; } echo "\t\t\t</div>\n"; echo "\t\t</div>\n"; echo "\t</div>\n"; echo "</div>\n"; }