retrieveCommissionsStatusesAsDropDown(); $commercials_array = $commissions->retrieveAllCommercialsAsDropDown(); $orders_status_name_array = array(); $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'"); while ($orders_status = tep_db_fetch_array($orders_status_query)) { $orders_status_name_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); $where = ""; if (isset($HTTP_GET_VARS['cID']) and $HTTP_GET_VARS['cID'] != "") { $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']); $where = "AND c.commercials_id = " . (int)$cID; } if (isset($HTTP_GET_VARS['search_comid']) and $HTTP_GET_VARS['search_comid'] != "") { $search = tep_db_prepare_input($HTTP_GET_VARS['search_comid']); $where = "AND c.id = " . (int)$search; } if (isset($HTTP_GET_VARS['search_oid']) and $HTTP_GET_VARS['search_oid'] != "") { $search = tep_db_prepare_input($HTTP_GET_VARS['search_oid']); $where = "AND o.orders_id = " . (int)$search; } if (isset($HTTP_GET_VARS['status']) and $HTTP_GET_VARS['status'] != "") { $status = tep_db_prepare_input($HTTP_GET_VARS['status']); $where .= "AND c.status = '" . $status . "'"; } $query_commission_raw = "select concat(cu.customers_firstname, ' ', cu.customers_lastname) as commercial_name, c.id, c.commercials_id, c.orders_id, c.date_created, c.date_modified, c.status, c.amount, c.comments, o.customers_name, o.orders_status, ot.value as orders_amount from commissions c, orders o, customers cu, orders_total ot where o.orders_id = c.orders_id and cu.customers_id = c.commercials_id and ot.orders_id = c.orders_id and ot.class = 'ot_total' $where order by date_modified DESC"; $comID = tep_db_prepare_input($HTTP_GET_VARS['comID']); if ( $action == 'edit' and $comID == '' ) {$action = "";} if (tep_not_null($action)) { switch ($action) { case 'update_com': $comID = tep_db_prepare_input($HTTP_GET_VARS['comID']); $commercials_id = tep_db_prepare_input($HTTP_POST_VARS['commercial_selected']); $orders_id = tep_db_prepare_input($HTTP_POST_VARS['orders_id']); $amount = tep_db_prepare_input($HTTP_POST_VARS['amount']); $status = tep_db_prepare_input($HTTP_POST_VARS['status']); $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']); if ($comID == "") { // nouvelle commissions $commissions->createCommissions($orders_id, $commercials_id, NULL, $amount, $status, $comments); } else { $commission = $commissions->retrieveCommission($comID); if ( $commission['amount'] == $amount ) $amount = NULL; if ( $commission['status'] == $status ) $status = NULL; if ( $commission['comments'] == $comments ) $comments = NULL; $commissions->updateCommission($comID, NULL, $amount, $status, $comments); // echo $comID, ";", $commercials_id, ";", $amount, ";", $status, ";", $comments, "\n"; } tep_redirect(tep_href_link(FILENAME_COMMISSIONS, tep_get_all_get_params(array('action')))); break; case 'deleteconfirm': $comID = tep_db_prepare_input($HTTP_GET_VARS['comID']); $commissions->deleteCommission($comID); tep_redirect(tep_href_link(FILENAME_COMMISSIONS, tep_get_all_get_params(array('comID', 'action')))); break; case 'changestatus': $comID = tep_db_prepare_input($HTTP_GET_VARS['comID']); $newstatus = tep_db_prepare_input($HTTP_GET_VARS['newstatus']); $commissions->updateCommission($comID, NULL, NULL, $newstatus); tep_redirect(tep_href_link(FILENAME_COMMISSIONS, tep_get_all_get_params(array('comID', 'action')))); break; case 'export': header("Content-Type: application/force-download\n"); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); header("Content-Disposition: attachment; filename=commission.csv"); echo "ID;DATE;AGENT;STATUS;COMMANDE;CLIENT;TOTAL_HT;COMMISSION\n"; $query = tep_db_query($query_commission_raw); while ($commission = tep_db_fetch_array($query)) { echo $commission['id'] . ";" . $commission['date_modified'] . ";" . $commission['commercial_name'] . ";" . $commission['status'] . ";" . $commission['orders_id'] . ";" . $commission['customers_name'] . ";" . $commission['orders_amount'] . ";" . $commission['amount'] . "\n"; } exit; break; } } if (($action == 'edit') && isset($HTTP_GET_VARS['comID'])) { $comID = tep_db_prepare_input($HTTP_GET_VARS['comID']); $query = tep_db_query("select id from commissions where id = '" . (int)$comID . "'"); $commission_exists = true; if (!tep_db_num_rows($query)) { $commission_exists = false; $messageStack->add(sprintf(ERROR_COMMISSION_DOES_NOT_EXIST, $oID), 'error'); } } ?> > <?php echo TITLE; ?> 0000003: icirelais/exapaq ?>
retrieveCommission($comID); $commissions->findCommissionAmount($commission['orders_id'], $commission_rule_description, $commission['commercials_id']); } else { $orders_id = (isset($HTTP_GET_VARS['orders_id']) ? tep_db_prepare_input($HTTP_GET_VARS['orders_id']) : ''); $customers_id = (isset($HTTP_GET_VARS['customers_id']) ? tep_db_prepare_input($HTTP_GET_VARS['customers_id']) : ''); $commercials_id = (isset($HTTP_GET_VARS['cID']) ? tep_db_prepare_input($HTTP_GET_VARS['cID']) : ''); if ( $orders_id != '' ) { if ( $customers_id == "" ) $customers_id = $commissions->findCustomerId($orders_id); if ( $commercials_id == "" ) $commercials_id = $commissions->findCommercialId($orders_id); } if ( $orders_id != '' and $commercials_id != '' ) { $amount = $commissions->findCommissionAmount($orders_id, $commission_rule_description, $commercials_id); } $commission = array( 'orders_id' => $orders_id, 'commercials_id' => $commercials_id, 'customers_id' => $customers_id, 'amount' => $amount ); } ?>
info['orders_status']); ?>
">  
'', 'text' => TEXT_ALL_COMMISSIONS)), $commissions_statuses), '', 'id="statusesList" onChange="this.form.submit();"'); ?>
'' . TEXT_INFO_HEADING_DELETE_COMMISSION . ''); $contents = array('form' => tep_draw_form('commissions', FILENAME_COMMISSIONS, tep_get_all_get_params(array('comID', 'action')) . 'comID=' . $cInfo->id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '

' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ''); $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (isset($cInfo) && is_object($cInfo)) { $heading[] = array('text' => '[' . $oInfo->orders_id . ']  ' . tep_datetime_short($oInfo->date_purchased) . ''); // -> ORED5066+MANORM155 // vd, 12/9/2013 : demande du client : suppression du bouton effacer /* $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_details.gif', IMAGE_DETAILS) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); */ $contents[] = array('align' => 'center', 'text' => tep_button(TEXT_BUTTON_EDIT, tep_href_link(FILENAME_COMMISSIONS, tep_get_all_get_params(array('comID', 'action')) . 'comID=' . $cInfo->id . '&action=edit'), '" TARGET="_blank"'). "  " . tep_button(TEXT_BUTTON_CREATE_COMMISSION, tep_href_link(FILENAME_COMMISSIONS, 'action=create&cID=' . $cID), '" TARGET="_blank"'). "  "); $contents[] = array('align' => 'center', 'text' => tep_button(TEXT_BUTTON_PAID, tep_href_link(FILENAME_COMMISSIONS, tep_get_all_get_params(array('comID', 'action')) . 'comID=' . $cInfo->id . '&action=changestatus&newstatus=R'), '" TARGET="_blank"'). "  " . tep_button(TEXT_BUTTON_DELETE, tep_href_link(FILENAME_COMMISSIONS, tep_get_all_get_params(array('comID', 'action')) . 'comID=' . $cInfo->id . '&action=delete'), '" TARGET="_blank"'). "  "); $contents[] = array('align' => 'center', 'text' => tep_button_new_window(TEXT_BUTTON_ORDER, tep_href_link(FILENAME_ORDERS, 'oID=' . $cInfo->orders_id . '&action=edit')). "  "); $contents[] = array('text' => '
' . TEXT_DATE_CREATED . ' ' . tep_date_short($cInfo->date_created)); $contents[] = array('text' => '
' . TEXT_COMMENT . ' ' . $cInfo->comments); } break; } echo ' ' . "\n"; //################### FIN FACTURE D'AVOIR ############################## ?>
id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?>
   
' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . ' ' . $commission['id']; ?> getCommissionStatusDescription($commission['status']); ?> id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
display_count($commissions_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_ORDERS); ?> display_links($commissions_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'oID', 'action'))); ?>
' . "\n"; if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { echo ' ' . "\n"; } ?> '' . TEXT_INFO_HEADING_DELETE_ORDER . ''); $contents = array('form' => tep_draw_form('orders', FILENAME_COMMISSIONS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '

' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ''); $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); } break; default: if (isset($oInfo) && is_object($oInfo)) { $heading[] = array('text' => '' . TEXT_INFO_HEADING_CREDIT_NOTE . '[' . $orders_avoir_id['orders_avoir_id'] . ']  '); if ($orders_avoir_id['orders_avoir_id'] == '') { $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_insert.gif', IMAGE_INSERT) . ''); } if ($orders_avoir_id['orders_avoir_id'] != '') { $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); //$contents[] = array( 'align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_invoice_avoir.gif', IMAGE_ORDERS_INVOICE_AVOIR)); $contents[] = array( 'align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_invoice_avoir.gif', IMAGE_ORDERS_INVOICE_AVOIR)); } $contents[] = array('text' => '
' . TEXT_DATE_ORDER_CREATED . ' ' . tep_date_short($oInfo->date_purchased)); if (tep_not_null($oInfo->last_modified)) $contents[] = array('text' => TEXT_DATE_ORDER_LAST_MODIFIED . ' ' . tep_date_short($oInfo->last_modified)); $contents[] = array('text' => '
' . TEXT_INFO_PAYMENT_METHOD . ' ' . $oInfo->payment_method); $contents[] = array('text' => '
' . TEXT_CUSTOMERS_ID . ' ' . $oInfo->customers_id); } break; } if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { echo '
' . "\n"; } echo '
' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo '
' . "\n"; echo '