private function validateDiscountAmount() { if (!helpers\Helper::isInt($this->discount_amount)) { $this->errors['discount_amount'] = 'Discount amount value must be int.'; } elseif (!helpers\Helper::validatePercentAmount($this->discount_amount)) { $this->errors['discount_amount'] = 'Discount amount value must be int between 1-100.'; } }
private function validateName() { if (helpers\Helper::isEmpty($this->name)) { $this->errors['name'] = 'Currency name can not be empty.'; } elseif (!helpers\Helper::isString($this->name)) { $this->errors['name'] = 'Currency must be a string value.'; } }
private function validateZip() { if (helpers\Helper::isEmpty($this->zip)) { $this->errors['zip'] = 'Zip code can not be empty.'; } elseif (!helpers\Helper::isString($this->zip)) { $this->errors['zip'] = 'Zip code must be a string value.'; } }
private function validateState() { if (helpers\Helper::isEmpty($this->state)) { $this->errors['state'] = 'State name can not be empty.'; } elseif (!helpers\Helper::isString($this->state)) { $this->errors['state'] = 'State must be a string value.'; } }
private function validateEmployerEmail() { if (!helpers\Helper::isValidEmail($this->employee_email)) { $this->errors['employee_email'] = 'Employer email is not valid email address.'; } }
private function validateEmail() { if (!helpers\Helper::isValidEmail($this->email)) { $this->errors['email'] = 'Enter valid email address.'; } }
$table_orders = ''; $order_counter = 0; if ($orders_products) { foreach ($orders_products as $single_order) { $order_counter++; //---- TODO - these should be as attached as relate entities to current entity --- $order = $db->find(new \models\Order(), ['id' => $single_order['order_id']]); $order_company = $db->find(new \models\Company(), ['id' => $order['company_id']]); $product = $db->find(new \models\Product(), ['id' => $single_order['product_id']]); $currency = $db->find(new \models\Currency(), ['id' => $single_order['currency_id']]); $shipping_country = $db->find(new \models\Country(), ['id' => $order['shipping_country_id']]); $shipping_city = $db->find(new \models\City(), ['id' => $order['shipping_city_id']]); //Show IP with human readable format $order_ip = \models\helpers\Helper::convertIpAddress($order['ip']); //Total amount is calculated dynamically. Aggregate values should not be saved in database. $total_price = \models\helpers\Helper::calculateTotalPrice($single_order['price'], $single_order['product_discount'], $single_order['company_discount'], $single_order['qty']); $table_orders .= '<div class="order-container">'; $table_orders .= '<h3>Order: ' . $order_counter . '</h3>'; $table_orders .= '<div class="order-row"><span>Company:</span><span>' . $order_company['company_name'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Product:</span><span>' . $product['product_name'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Quantity:</span><span>' . $single_order['qty'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Product discount:</span><span>' . $single_order['product_discount'] . ' %</span></div>'; $table_orders .= '<div class="order-row"><span>Company discount:</span><span>' . $single_order['company_discount'] . ' %</span></div>'; $table_orders .= '<div class="order-row"><span>Shipping Country:</span><span>' . $shipping_country['country'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Shipping City:</span><span>' . $shipping_city['city'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Zip:</span><span>' . $shipping_city['zip'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Shipping address:</span><span>' . $order['shipping_address'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Currency:</span><span>' . $currency['name'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Price:</span><span>' . $single_order['price'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Note:</span><span>' . $order['note'] . '</span></div>'; $table_orders .= '<div class="order-row"><span>Ip:</span><span>' . $order_ip . '</span></div>';
private function validatePrice() { if (!helpers\Helper::isValidFloat($this->product_price)) { $this->errors['product_price'] = 'Product price must me float.'; } }
/** * @param mixed $ip * @return Order */ public function setIp($ip) { if (helpers\Helper::isValidIpAddress($ip)) { $this->ip = ip2long($ip); } else { $this->ip = false; } return $this; }
private function validateCurrencyId() { if (!helpers\Helper::isInt($this->currency_id)) { $this->errors['currency_id'] = 'Currency ID value must be int.'; } }