本文整理汇总了PHP中date_to_mysql函数的典型用法代码示例。如果您正苦于以下问题:PHP date_to_mysql函数的具体用法?PHP date_to_mysql怎么用?PHP date_to_mysql使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_to_mysql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: db_array
public function db_array()
{
$db_array = parent::db_array();
$db_array['task_finish_date'] = date_to_mysql($db_array['task_finish_date']);
$db_array['task_price'] = standardize_amount($db_array['task_price']);
return $db_array;
}
示例2: save
public function save()
{
$this->load->model('invoices/mdl_items');
$this->load->model('invoices/mdl_invoices');
$invoice_id = $this->input->post('invoice_id');
if ($this->mdl_invoices->run_validation('validation_rules_save_invoice')) {
$items = json_decode($this->input->post('items'));
foreach ($items as $item) {
if ($item->item_name) {
$this->mdl_items->save($invoice_id, isset($item->item_id) ? $item->item_id : NULL, $item);
}
}
$db_array = array('invoice_number' => $this->input->post('invoice_number'), 'invoice_terms' => $this->input->post('invoice_terms'), 'invoice_date_created' => date_to_mysql($this->input->post('invoice_date_created')), 'invoice_date_due' => date_to_mysql($this->input->post('invoice_date_due')));
$this->mdl_invoices->save($invoice_id, $db_array);
$response = array('success' => 1);
} else {
$this->load->helper('json_error');
$response = array('success' => 0, 'validation_errors' => json_errors());
}
if ($this->input->post('custom')) {
$db_array = array();
foreach ($this->input->post('custom') as $custom) {
// I hate myself for this...
$db_array[str_replace(']', '', str_replace('custom[', '', $custom['name']))] = $custom['value'];
}
$this->load->model('custom_fields/mdl_invoice_custom');
$this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
}
echo json_encode($response);
}
示例3: save
public function save()
{
$this->load->model('quotes/mdl_quote_items');
$this->load->model('quotes/mdl_quotes');
$this->load->model('item_lookups/mdl_item_lookups');
$this->load->library('encrypt');
$quote_id = $this->input->post('quote_id');
$this->mdl_quotes->set_id($quote_id);
if ($this->mdl_quotes->run_validation('validation_rules_save_quote')) {
$items = json_decode($this->input->post('items'));
foreach ($items as $item) {
if ($item->item_name) {
$item->item_quantity = $item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0);
$item->item_price = $item->item_quantity ? standardize_amount($item->item_price) : floatval(0);
$item->item_discount_amount = $item->item_discount_amount ? standardize_amount($item->item_discount_amount) : null;
$item->item_product_id = $item->item_product_id ? $item->item_product_id : null;
$item_id = $item->item_id ?: null;
unset($item->item_id);
$this->mdl_quote_items->save($item_id, $item);
}
}
if ($this->input->post('quote_discount_amount') === '') {
$quote_discount_amount = floatval(0);
} else {
$quote_discount_amount = $this->input->post('quote_discount_amount');
}
if ($this->input->post('quote_discount_percent') === '') {
$quote_discount_percent = floatval(0);
} else {
$quote_discount_percent = $this->input->post('quote_discount_percent');
}
// Generate new quote number if needed
$quote_number = $this->input->post('quote_number');
$quote_status_id = $this->input->post('quote_status_id');
if (empty($quote_number) && $quote_status_id != 1) {
$quote_group_id = $this->mdl_quotes->get_invoice_group_id($quote_id);
$quote_number = $this->mdl_quotes->get_quote_number($quote_group_id);
}
$db_array = array('quote_number' => $quote_number, 'quote_date_created' => date_to_mysql($this->input->post('quote_date_created')), 'quote_date_expires' => date_to_mysql($this->input->post('quote_date_expires')), 'quote_status_id' => $quote_status_id, 'quote_password' => $this->input->post('quote_password'), 'notes' => $this->input->post('notes'), 'quote_discount_amount' => $quote_discount_amount, 'quote_discount_percent' => $quote_discount_percent);
$this->mdl_quotes->save($quote_id, $db_array);
// Recalculate for discounts
$this->load->model('quotes/mdl_quote_amounts');
$this->mdl_quote_amounts->calculate($quote_id);
$response = array('success' => 1);
} else {
$this->load->helper('json_error');
$response = array('success' => 0, 'validation_errors' => json_errors());
}
if ($this->input->post('custom')) {
$db_array = array();
foreach ($this->input->post('custom') as $custom) {
// I hate myself for this...
$db_array[str_replace(']', '', str_replace('custom[', '', $custom['name']))] = $custom['value'];
}
$this->load->model('custom_fields/mdl_quote_custom');
$this->mdl_quote_custom->save_custom($quote_id, $db_array);
}
echo json_encode($response);
}
示例4: increment_user_date
/**
* Adds interval to user formatted date and returns user formatted date
* To be used when date is being output back to user
* @param $date - user formatted date
* @param $increment - interval (1D, 2M, 1Y, etc)
* @return user formatted date
*/
function increment_user_date($date, $increment)
{
$CI =& get_instance();
$mysql_date = date_to_mysql($date);
$new_date = new DateTime($mysql_date);
$new_date->add(new DateInterval('P' . $increment));
return $new_date->format($CI->mdl_settings->setting('date_format'));
}
示例5: save
public function save()
{
$this->load->model('quotes/mdl_quote_items');
$this->load->model('quotes/mdl_quotes');
$this->load->model('item_lookups/mdl_item_lookups');
$this->load->library('encrypt');
$quote_id = $this->input->post('quote_id');
$this->mdl_quotes->set_id($quote_id);
if ($this->mdl_quotes->run_validation('validation_rules_save_quote')) {
$items = json_decode($this->input->post('items'));
# print_r($items);
foreach ($items as $item) {
if ($item->item_name) {
$item->item_quantity = standardize_amount($item->item_quantity);
$item->item_price = standardize_amount($item->item_price);
$item->item_discount_amount = standardize_amount($item->item_discount_amount);
# $item->item_cost = $item_cost;
$item_id = $item->item_id ?: NULL;
$save_item_as_lookup = isset($item->save_item_as_lookup) ? $item->save_item_as_lookup : 0;
unset($item->item_id, $item->save_item_as_lookup);
$this->mdl_quote_items->save($quote_id, $item_id, $item);
if ($save_item_as_lookup) {
$db_array = array('item_name' => $item->item_name, 'item_description' => $item->item_description, 'item_price' => $item->item_price);
$this->mdl_item_lookups->save(NULL, $db_array);
}
}
}
if ($this->input->post('quote_discount_amount') === '') {
$quote_discount_amount = floatval(0);
} else {
$quote_discount_amount = $this->input->post('quote_discount_amount');
}
if ($this->input->post('quote_discount_percent') === '') {
$quote_discount_percent = floatval(0);
} else {
$quote_discount_percent = $this->input->post('quote_discount_percent');
}
$db_array = array('quote_total_cost' => $this->input->post('quote_total_cost'), 'quote_nett_profit' => $this->input->post('quote_nett_profit'), 'quote_total_profit' => $this->input->post('quote_total_profit'), 'quote_number' => $this->input->post('quote_number'), 'quote_date_created' => date_to_mysql($this->input->post('quote_date_created')), 'quote_date_expires' => date_to_mysql($this->input->post('quote_date_expires')), 'quote_status_id' => $this->input->post('quote_status_id'), 'quote_password' => $this->input->post('quote_password'), 'notes' => $this->input->post('notes'), 'quote_discount_amount' => $quote_discount_amount, 'quote_discount_percent' => $quote_discount_percent);
$this->mdl_quotes->save($quote_id, $db_array);
// Recalculate for discounts
$this->load->model('quotes/mdl_quote_amounts');
$this->mdl_quote_amounts->calculate($quote_id);
$response = array('success' => 1);
} else {
$this->load->helper('json_error');
$response = array('success' => 0, 'validation_errors' => json_errors());
}
if ($this->input->post('custom')) {
$db_array = array();
foreach ($this->input->post('custom') as $custom) {
// I hate myself for this...
$db_array[str_replace(']', '', str_replace('custom[', '', $custom['name']))] = $custom['value'];
}
$this->load->model('custom_fields/mdl_quote_custom');
$this->mdl_quote_custom->save_custom($quote_id, $db_array);
}
echo json_encode($response);
}
示例6: payment_history
public function payment_history($from_date = NULL, $to_date = NULL)
{
$this->load->model('payments/mdl_payments');
if ($from_date and $to_date) {
$from_date = date_to_mysql($from_date);
$to_date = date_to_mysql($to_date);
$this->mdl_payments->where('payment_date >=', $from_date);
$this->mdl_payments->where('payment_date <=', $to_date);
}
return $this->mdl_payments->get()->result();
}
示例7: db_array
public function db_array()
{
$db_array = parent::db_array();
$db_array['recur_start_date'] = date_to_mysql($db_array['recur_start_date']);
$db_array['recur_next_date'] = $db_array['recur_start_date'];
if ($db_array['recur_end_date']) {
$db_array['recur_end_date'] = date_to_mysql($db_array['recur_end_date']);
} else {
$db_array['recur_end_date'] = '0000-00-00';
}
return $db_array;
}
示例8: db_array
public function db_array()
{
$db_array = parent::db_array();
// Get the client id for the submitted invoice
$this->load->model('clients/mdl_clients');
$db_array['client_id'] = $this->mdl_clients->client_lookup($db_array['client_name']);
unset($db_array['client_name']);
$db_array['invoice_date_created'] = date_to_mysql($db_array['invoice_date_created']);
// Calculate the invoice date due
$invoice_due_date = new DateTime($db_array['invoice_date_created']);
$invoice_due_date->add(new DateInterval('P' . $this->mdl_settings->setting('invoices_due_after') . 'D'));
$db_array['invoice_date_due'] = $invoice_due_date->format('Y-m-d');
// Get the next invoice number for the selected invoice group
$this->load->model('invoice_groups/mdl_invoice_groups');
$db_array['invoice_number'] = $this->mdl_invoice_groups->generate_invoice_number($db_array['invoice_group_id']);
$db_array['invoice_terms'] = $this->mdl_settings->setting('default_invoice_terms');
// Generate the unique url key
$db_array['invoice_url_key'] = $this->get_url_key();
return $db_array;
}
示例9: save
public function save()
{
$this->load->model('invoices/mdl_items');
$this->load->model('invoices/mdl_invoices');
$this->load->model('item_lookups/mdl_item_lookups');
$invoice_id = $this->input->post('invoice_id');
$this->mdl_invoices->set_id($invoice_id);
if ($this->mdl_invoices->run_validation('validation_rules_save_invoice')) {
$items = json_decode($this->input->post('items'));
foreach ($items as $item) {
if ($item->item_name) {
$item->item_quantity = standardize_amount($item->item_quantity);
$item->item_price = standardize_amount($item->item_price);
$item_id = $item->item_id ?: NULL;
$save_item_as_lookup = isset($item->save_item_as_lookup) ? $item->save_item_as_lookup : 0;
unset($item->item_id, $item->save_item_as_lookup);
$this->mdl_items->save($invoice_id, $item_id, $item);
if ($save_item_as_lookup) {
$db_array = array('item_name' => $item->item_name, 'item_description' => $item->item_description, 'item_price' => $item->item_price);
$this->mdl_item_lookups->save(NULL, $db_array);
}
}
}
$db_array = array('invoice_number' => $this->input->post('invoice_number'), 'invoice_terms' => $this->input->post('invoice_terms'), 'invoice_date_created' => date_to_mysql($this->input->post('invoice_date_created')), 'invoice_date_due' => date_to_mysql($this->input->post('invoice_date_due')), 'invoice_status_id' => $this->input->post('invoice_status_id'));
$this->mdl_invoices->save($invoice_id, $db_array);
$response = array('success' => 1);
} else {
$this->load->helper('json_error');
$response = array('success' => 0, 'validation_errors' => json_errors());
}
if ($this->input->post('custom')) {
$db_array = array();
foreach ($this->input->post('custom') as $custom) {
// I hate myself for this...
$db_array[str_replace(']', '', str_replace('custom[', '', $custom['name']))] = $custom['value'];
}
$this->load->model('custom_fields/mdl_invoice_custom');
$this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
}
echo json_encode($response);
}
示例10: index
/**
* index
*
* @param String vid id del cliente en la bd
*/
public function index($cli = null)
{
$fi = $this->input->post('fi');
$ff = $this->input->post('ff');
if ($fi == FALSE) {
$fi = date('d/m/Y');
}
if ($ff == FALSE) {
$ff = date('d/m/Y');
}
$content['fi'] = $fi;
$content['ff'] = $ff;
$fi = date_to_mysql($fi) . ' 00:00';
$ff = date_to_mysql($ff) . ' 23:00';
if (is_null($cli)) {
$cli = $this->input->post('cli');
if ($cli == FALSE) {
$cli = NULL;
}
}
$fechas_seleccionadas_comision = array('fi' => $fi, 'ff' => $ff);
$content['cli'] = $cli;
// Informacion del cliente
$content['cliente'] = $this->proy_model->get($cli);
// Recuperar la informacion de los referente 1
$content['referentes_uno'] = $this->proy_model->get_referrings($cli, 1, array('fi' => $fi, 'ff' => $ff));
// echo json_encode($content);
// Recuperar la informacion de los referente 2
$content['referentes_dos'] = $this->proy_model->get_referrings($cli, 2, array('fi' => $fi, 'ff' => $ff));
//adicion de estado pago
$content['payed'] = $this->proy_model->checLiqProm(date_to_mysql($content['fi']), date_to_mysql($content['ff']), $cli);
$this->session->set_userdata($fechas_seleccionadas_comision);
// que tengan ventas.
// Set comisions dates to Session
$this->load->view('comisiones_format_view', $content);
//$this->run('comisiones_format_view',$content,' Liquidación de Comisiones ', $menu, array('date', 'jquery.datePicker'), array('datePicker'));
}
示例11: db_array
public function db_array()
{
$db_array = parent::db_array();
$db_array['payment_date'] = date_to_mysql($db_array['payment_date']);
return $db_array;
}
示例12: db_array
public function db_array()
{
$db_array = parent::db_array();
// Get the client id for the submitted invoice
$this->load->model('clients/mdl_clients');
$db_array['client_id'] = $this->mdl_clients->client_lookup($db_array['client_name']);
unset($db_array['client_name']);
$db_array['invoice_date_created'] = date_to_mysql($db_array['invoice_date_created']);
$db_array['invoice_date_due'] = $this->get_date_due($db_array['invoice_date_created']);
$db_array['invoice_number'] = $this->get_invoice_number($db_array['invoice_group_id']);
$db_array['invoice_terms'] = $this->mdl_settings->setting('default_invoice_terms');
if (!isset($db_array['invoice_status_id'])) {
$db_array['invoice_status_id'] = 1;
}
// Generate the unique url key
$db_array['invoice_url_key'] = $this->get_url_key();
return $db_array;
}
示例13: save
public function save()
{
$this->load->model('invoices/mdl_items');
$this->load->model('invoices/mdl_invoices');
$this->load->model('item_lookups/mdl_item_lookups');
$invoice_id = $this->input->post('invoice_id');
$this->mdl_invoices->set_id($invoice_id);
if ($this->mdl_invoices->run_validation('validation_rules_save_invoice')) {
$items = json_decode($this->input->post('items'));
foreach ($items as $item) {
// Check if an item has either a quantity + price or name or description
if (!empty($item->item_name)) {
$item->item_quantity = $item->item_quantity ? standardize_amount($item->item_quantity) : floatval(0);
$item->item_price = $item->item_quantity ? standardize_amount($item->item_price) : floatval(0);
$item->item_discount_amount = $item->item_discount_amount ? standardize_amount($item->item_discount_amount) : null;
$item->item_product_id = $item->item_product_id ? $item->item_product_id : null;
$item_id = $item->item_id ?: null;
unset($item->item_id);
$this->mdl_items->save($item_id, $item);
} else {
// Throw an error message and use the form validation for that
$this->load->library('form_validation');
$this->form_validation->set_rules('item_name', trans('item'), 'required');
$this->form_validation->run();
$response = array('success' => 0, 'validation_errors' => array('item_name' => form_error('item_name', '', '')));
echo json_encode($response);
exit;
}
}
$invoice_status = $this->input->post('invoice_status_id');
if ($this->input->post('invoice_discount_amount') === '') {
$invoice_discount_amount = floatval(0);
} else {
$invoice_discount_amount = $this->input->post('invoice_discount_amount');
}
if ($this->input->post('invoice_discount_percent') === '') {
$invoice_discount_percent = floatval(0);
} else {
$invoice_discount_percent = $this->input->post('invoice_discount_percent');
}
// Generate new invoice number if needed
$invoice_number = $this->input->post('invoice_number');
if (empty($invoice_number) && $invoice_status != 1) {
$invoice_group_id = $this->mdl_invoices->get_invoice_group_id($invoice_id);
$invoice_number = $this->mdl_invoices->get_invoice_number($invoice_group_id);
}
$db_array = array('invoice_number' => $invoice_number, 'invoice_terms' => $this->input->post('invoice_terms'), 'invoice_date_created' => date_to_mysql($this->input->post('invoice_date_created')), 'invoice_date_due' => date_to_mysql($this->input->post('invoice_date_due')), 'invoice_password' => $this->input->post('invoice_password'), 'invoice_status_id' => $invoice_status, 'payment_method' => $this->input->post('payment_method'), 'invoice_discount_amount' => $invoice_discount_amount, 'invoice_discount_percent' => $invoice_discount_percent);
// check if status changed to sent, the feature is enabled and settings is set to sent
if ($this->config->item('disable_read_only') === false) {
if ($invoice_status == $this->mdl_settings->setting('read_only_toggle')) {
$db_array['is_read_only'] = 1;
}
}
$this->mdl_invoices->save($invoice_id, $db_array);
// Recalculate for discounts
$this->load->model('invoices/mdl_invoice_amounts');
$this->mdl_invoice_amounts->calculate($invoice_id);
$response = array('success' => 1);
} else {
$this->load->helper('json_error');
$response = array('success' => 0, 'validation_errors' => json_errors());
}
// Save all custom fields
if ($this->input->post('custom')) {
$db_array = array();
foreach ($this->input->post('custom') as $custom) {
$db_array[str_replace(']', '', str_replace('custom[', '', $custom['name']))] = $custom['value'];
}
$this->load->model('custom_fields/mdl_invoice_custom');
$this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
}
echo json_encode($response);
}
示例14: save
public function save()
{
$this->load->model('invoices/mdl_items');
$this->load->model('invoices/mdl_invoices');
$this->load->model('item_lookups/mdl_item_lookups');
$invoice_id = $this->input->post('invoice_id');
$this->mdl_invoices->set_id($invoice_id);
if ($this->mdl_invoices->run_validation('validation_rules_save_invoice')) {
$items = json_decode($this->input->post('items'));
foreach ($items as $item) {
// Check if an item has either a quantity + price or name or description
if (!empty($item->item_quantity) && !empty($item->item_price) || !empty($item->item_name) || !empty($item->item_description)) {
$item->item_quantity = standardize_amount($item->item_quantity);
$item->item_price = standardize_amount($item->item_price);
$item->item_discount_amount = standardize_amount($item->item_discount_amount);
$item_id = $item->item_id ?: NULL;
unset($item->item_id, $item->save_item_as_lookup);
$this->mdl_items->save($invoice_id, $item_id, $item);
} else {
// Throw an error message and use the form validation for that
$this->load->library('form_validation');
$this->form_validation->set_rules('item_name', lang('item'), 'required');
$this->form_validation->set_rules('item_description', lang('description'), 'required');
$this->form_validation->set_rules('item_quantity', lang('quantity'), 'required');
$this->form_validation->set_rules('item_price', lang('price'), 'required');
$this->form_validation->run();
$response = array('success' => 0, 'validation_errors' => array('item_name' => form_error('item_name', '', ''), 'item_description' => form_error('item_description', '', ''), 'item_quantity' => form_error('item_quantity', '', ''), 'item_price' => form_error('item_price', '', '')));
echo json_encode($response);
exit;
}
}
$invoice_status = $this->input->post('invoice_status_id');
if ($this->input->post('invoice_discount_amount') === '') {
$invoice_discount_amount = floatval(0);
} else {
$invoice_discount_amount = $this->input->post('invoice_discount_amount');
}
if ($this->input->post('invoice_discount_percent') === '') {
$invoice_discount_percent = floatval(0);
} else {
$invoice_discount_percent = $this->input->post('invoice_discount_percent');
}
$db_array = array('invoice_number' => $this->input->post('invoice_number'), 'invoice_terms' => $this->input->post('invoice_terms'), 'invoice_date_created' => date_to_mysql($this->input->post('invoice_date_created')), 'invoice_date_due' => date_to_mysql($this->input->post('invoice_date_due')), 'invoice_password' => $this->input->post('invoice_password'), 'invoice_status_id' => $invoice_status, 'payment_method' => $this->input->post('payment_method'), 'invoice_discount_amount' => $invoice_discount_amount, 'invoice_discount_percent' => $invoice_discount_percent);
// check if status changed to sent, the feature is enabled and settings is set to sent
if ($invoice_status == 2 && $this->config->item('disable_read_only') == FALSE && $this->mdl_settings->setting('read_only_toggle') == 'sent') {
$db_array['is_read_only'] = 1;
}
// check if status changed to viewed, the feature is enabled and settings is set to viewed
if ($invoice_status == 3 && $this->config->item('disable_read_only') == FALSE && $this->mdl_settings->setting('read_only_toggle') == 'viewed') {
$db_array['is_read_only'] = 1;
}
// check if status changed to paid and the feature is enabled
if ($invoice_status == 4 && $this->config->item('disable_read_only') == FALSE && $this->mdl_settings->setting('read_only_toggle') == 'paid') {
$db_array['is_read_only'] = 1;
}
$this->mdl_invoices->save($invoice_id, $db_array);
// Recalculate for discounts
$this->load->model('invoices/mdl_invoice_amounts');
$this->mdl_invoice_amounts->calculate($invoice_id);
$response = array('success' => 1);
} else {
$this->load->helper('json_error');
$response = array('success' => 0, 'validation_errors' => json_errors());
}
if ($this->input->post('custom')) {
$db_array = array();
foreach ($this->input->post('custom') as $custom) {
// I hate myself for this...
$db_array[str_replace(']', '', str_replace('custom[', '', $custom['name']))] = $custom['value'];
}
$this->load->model('custom_fields/mdl_invoice_custom');
$this->mdl_invoice_custom->save_custom($invoice_id, $db_array);
}
echo json_encode($response);
}
示例15: db_array
public function db_array()
{
$db_array = parent::db_array();
// Get the client id for the submitted quote
$this->load->model('clients/mdl_clients');
$db_array['client_id'] = $this->mdl_clients->client_lookup($db_array['client_name']);
unset($db_array['client_name']);
$db_array['quote_date_created'] = date_to_mysql($db_array['quote_date_created']);
$db_array['quote_date_expires'] = $this->get_date_due($db_array['quote_date_created']);
$db_array['notes'] = $this->mdl_settings->setting('default_quote_notes');
if (!isset($db_array['quote_status_id'])) {
$db_array['quote_status_id'] = 1;
}
$generate_quote_number = $this->mdl_settings->setting('generate_quote_number_for_draft');
if ($db_array['quote_status_id'] === 1 && $generate_quote_number == 1) {
$db_array['quote_number'] = $this->get_quote_number($db_array['invoice_group_id']);
} elseif ($db_array['quote_status_id'] != 1) {
$db_array['quote_number'] = $this->get_quote_number($db_array['invoice_group_id']);
} else {
$db_array['quote_number'] = '';
}
// Generate the unique url key
$db_array['quote_url_key'] = $this->get_url_key();
return $db_array;
}