Changeset 3033873
- Timestamp:
- 02/10/2024 02:10:48 AM (13 months ago)
- Location:
- wp-easy-crm
- Files:
-
- 41 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-easy-crm/trunk/easy-crm.php
r3031193 r3033873 4 4 * Plugin Name: Easy CRM 5 5 * Description: Collect new leads, manage clients, quotations, invoices, tasks and more for your entire team 6 * Version: 1.0.1 86 * Version: 1.0.19 7 7 * Author: IT-iCO SRL 8 8 * Author URI: https://it-ico.com … … 47 47 nombrecontacto varchar(500) NOT NULL, 48 48 nota varchar(2000), 49 tagsrelations varchar(2000), 49 50 clientsource varchar(150), 50 51 telefono varchar(500), … … 189 190 190 191 192 $tagTable = $wpdb->prefix . 'easytags'; 193 194 // Create tags Table if not exist 195 196 $sqltags = "CREATE TABLE $tagTable ( 197 id int(11) NOT NULL AUTO_INCREMENT, 198 tagtitle varchar(200) NOT NULL, 199 tagcolor varchar(200), 200 created_at datetime NOT NULL, 201 PRIMARY KEY tag_id (id) 202 ) $charset_collate;"; 203 204 add_option( "clients_db_version", "1.0" ); 205 206 // Include Upgrade Script 207 require_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); 208 209 // Create Table 210 dbDelta( $sqltags ); 211 212 213 191 214 192 215 $logclientTable = $wpdb->prefix . 'logclient'; … … 215 238 dbDelta( $sqllog ); 216 239 217 218 219 220 221 240 } 222 241 function eacr_uninstall() { … … 232 251 $logclientTable = $wpdb->prefix . 'logclient'; 233 252 $accountingregionTable = $wpdb->prefix . 'eacraccountingregion'; 253 $tagTable = $wpdb->prefix . 'easytags'; 254 234 255 235 256 $wpdb->query( "DROP TABLE IF EXISTS $quoteLineclientTable" ); … … 249 270 250 271 $wpdb->query( "DROP TABLE IF EXISTS $accountingregionTable" ); 272 delete_option("clients_db_version"); 273 274 $wpdb->query( "DROP TABLE IF EXISTS $tagTable" ); 251 275 delete_option("clients_db_version"); 252 276 … … 478 502 $taskTable = $wpdb->prefix . 'task'; 479 503 $clientTable = $wpdb->prefix . 'clients'; 504 505 // Add buttons to filter tasks 506 echo ' 507 <div style="margin-bottom: 10px;"> 508 <button onclick="filterTasks(\'started\')">Show Started Tasks</button> 509 <button onclick="filterTasks(\'due\')">Show Due Tasks</button> 510 <button onclick="filterTasks(\'all\')">Show All Open Tasks</button> 511 </div> 512 '; 513 514 // JavaScript function to filter tasks 515 echo ' 516 <script> 517 function filterTasks(type) { 518 // Get all task cards 519 var tasks = document.getElementsByClassName("task-card"); 520 521 // Loop through all task cards 522 for (var i = 0; i < tasks.length; i++) { 523 var task = tasks[i]; 524 var start = task.dataset.start; 525 var end = task.dataset.end; 526 527 // Show or hide task cards based on filter type 528 if (type === "started" && new Date(start) > new Date()) { 529 task.style.display = "none"; 530 } else if (type === "due" && new Date(end) > new Date()) { 531 task.style.display = "none"; 532 } else if (type === "all") { 533 task.style.display = "block"; 534 } else { 535 task.style.display = "block"; 536 } 537 } 538 } 539 </script> 540 '; 541 542 // Fetch tasks based on filter (not implemented yet) 480 543 $allmyopentasks = $wpdb->get_results( 481 544 $wpdb->prepare( 482 "SELECT * from $taskTable WHERE useridfk = %d AND completed = 0 ORDER BY created_at DESC",$myuserid483 ), ARRAY_A545 "SELECT * FROM $taskTable WHERE useridfk = %d AND completed = 0 ORDER BY created_at DESC", $myuserid 546 ), ARRAY_A 484 547 ); 485 548 549 // Add CSS for two-column layout and task card width adjustment 550 echo " 551 <style> 552 /* CSS for two-column layout */ 553 .task-container { 554 display: grid; 555 grid-template-columns: repeat(2, 1fr); /* Two columns with equal width */ 556 gap: 10px; /* Smaller gap between tasks */ 557 } 558 559 .task-card { 560 box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); 561 transition: 0.3s; 562 border-radius: 5px; 563 background-color: #e0e4cc; 564 /* Limit task card width to fit within the widget space */ 565 /*max-width: calc(50% - 10px); Adjust according to your widget space and gap */ 566 padding: 20px; /* Moved padding from .task-card to .task-container */ 567 margin-bottom: 10px; /* Added margin to create space between tasks */ 568 } 569 570 .task-title { 571 font-size: 16px; 572 margin-bottom: 10px; /* Added margin to create space between title and button */ 573 } 574 575 .task-buttons { 576 display: flex; 577 align-items: center; 578 } 579 580 .task-buttons a { 581 margin-left: 10px; /* Added margin between buttons */ 582 } 583 </style> 584 "; 585 486 586 if(count($allmyopentasks) > 0){ 587 // Wrap tasks in a container with two columns 588 echo '<div class="task-container">'; 589 487 590 // Reverse the order of tasks 488 591 $reversedTasks = array_reverse($allmyopentasks); 489 592 foreach($reversedTasks as $singletask){ 490 593 // Start of card container with shadow, padding, and margin for card-like appearance 491 echo '<div style="box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); transition: 0.3s; border-radius: 5px; margin: 5px; margin-bottom:15px; padding: 20px; background-color: #e0e4cc;">';594 echo '<div class="task-card" data-start="' . $singletask['start_at'] . '" data-end="' . $singletask['end_at'] . '">'; 492 595 493 596 // Title and button container 494 echo '<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">'; 495 // Task title 496 echo '<div style="flex-grow: 1; font-size: 16px;"><b> # '.esc_html($singletask['tasktitle']).'</b></div>'; 497 597 echo '<div class="task-title"><b> # '.esc_html($singletask['tasktitle']).'</b></div>'; 598 echo '<div class="task-buttons">'; 498 599 // Buttons and client name 499 600 $clientid = sanitize_text_field($singletask['clientidfk']); … … 502 603 $clientdetails = $wpdb->get_row($wpdb->prepare("SELECT * FROM $clientTable WHERE id = %d", $clientid)); 503 604 $clientname = $clientdetails->clientname; 504 echo '< div><a class="button button-secondary" href="admin.php?page=wp-easy-crm-perfil&id='.$clientid.'">'.$clientname.'</a><span> </span></div>';605 echo '<a class="button button-secondary" href="admin.php?page=wp-easy-crm-perfil&id='.$clientid.'">'.$clientname.'</a>'; 505 606 } else { 506 echo '< div><a class="button button-secondary" href="admin.php?page=wp-easy-crm-tasks">'.__('Tasks', 'wp-easy-crm').'</a><span> </span></div>';607 echo '<a class="button button-secondary" href="admin.php?page=wp-easy-crm-tasks">'.__('Tasks', 'wp-easy-crm').'</a>'; 507 608 } 508 echo '</div>'; // End of title andbutton container609 echo '</div>'; // End of button container 509 610 510 611 // Date information included within the main card container … … 516 617 echo '<div style="padding: 10px; background-color: #F2F2F2; border-radius: 5px; margin-top: 10px;">'; // Added margin-top for spacing 517 618 if ($startDateTime <= $currentDateTime) { 518 echo '<span style="color: rgba(255, 0, 0, 0.5);font-weight: bold; font-size: 1 3px;">Start: ' . htmlspecialchars($startDateTime->format('Y-m-d')) . '</span>';619 echo '<span style="color: rgba(255, 0, 0, 0.5);font-weight: bold; font-size: 11px;">Start: ' . htmlspecialchars($startDateTime->format('Y-m-d')) . '</span>'; 519 620 } else { 520 echo '<span style="color: grey;font-size: 1 3px;">Start: ' . htmlspecialchars($startDateTime->format('Y-m-d')) . '</span>';621 echo '<span style="color: grey;font-size: 11px;">Start: ' . htmlspecialchars($startDateTime->format('Y-m-d')) . '</span>'; 521 622 } 522 623 523 624 if ($endDateTime <= $currentDateTime) { 524 echo '<span style="color: rgba(255, 0, 0, 0.5);font-weight: bold;margin-left: 1em;font-size: 1 3px;">Due: ' . htmlspecialchars($endDateTime->format('Y-m-d')) . '</span>';625 echo '<span style="color: rgba(255, 0, 0, 0.5);font-weight: bold;margin-left: 1em;font-size: 11px;">Due: ' . htmlspecialchars($endDateTime->format('Y-m-d')) . '</span>'; 525 626 } else { 526 echo '<span style="color: grey;margin-left: 1em;font-size: 1 3px;">Due: ' . htmlspecialchars($endDateTime->format('Y-m-d')) . '</span>';627 echo '<span style="color: grey;margin-left: 1em;font-size: 11px;">Due: ' . htmlspecialchars($endDateTime->format('Y-m-d')) . '</span>'; 527 628 } 528 629 echo '</div>'; // End of date information container 529 630 530 631 // Task description 531 632 echo '<div>'.wp_kses_post($singletask['taskdescription']).'</div>'; 532 633 533 534 535 634 echo '</div>'; // End of the main card container 536 635 //echo '<hr/>'; // Separator (consider styling or removing for spacing) 537 636 } 538 } 539 540 541 542 543 544 // echo '<div class="eacr-dashboard-widget">Hello, world!</div>'; 545 } 637 638 echo '</div>'; // End of task container 639 } 640 } 641 642 546 643 547 644 function eacr_register_dashboard_widget() { … … 611 708 add_submenu_page("wp-easy-crm","Tasks",__('Tasks', 'wp-easy-crm'),"edit_others_posts","wp-easy-crm-tasks","eacr_tasks_call"); 612 709 add_submenu_page("wp-easy-crm","Quotes / Invoices",__('Quotes / Invoices', 'wp-easy-crm'),"edit_others_posts","wp-easy-crm-quotes","eacr_quotes_call"); 710 add_submenu_page("wp-easy-crm","Tags",__('Tags', 'wp-easy-crm'),"edit_others_posts","wp-easy-crm-tags","eacr_tags_call"); 613 711 add_submenu_page("wp-easy-crm","Forms",__('Forms', 'wp-easy-crm'),"edit_others_posts","wp-easy-crm-forms","eacr_forms_call"); 614 712 add_submenu_page("wp-easy-crm","Settings",__('Settings', 'wp-easy-crm'),"manage_options","wp-easy-crm-settings","eacr_settings_call"); 713 add_submenu_page("wp-easy-crm","Accounting Regions",__('Accounting Regions', 'wp-easy-crm'),"manage_options","wp-easy-crm-accregions","eacr_accregions_call"); 714 615 715 616 716 … … 626 726 } 627 727 728 function eacr_accregions_call(){ 729 730 include_once EASYCRM_PLUGIN_DIR_PATH.'/views/accountingregions.php'; 731 } 732 733 function eacr_tags_call(){ 734 735 include_once EASYCRM_PLUGIN_DIR_PATH.'/views/tagsView.php'; 736 } 628 737 629 738 function eacr_client_quoteview_call(){ -
wp-easy-crm/trunk/readme.txt
r3031193 r3033873 4 4 Requires at least: 5.9 5 5 Tested up to: 6.4.3 6 Stable tag: 1.0.1 86 Stable tag: 1.0.19 7 7 Contributors: sunnysonic 8 8 License: GPLv2 or later … … 60 60 61 61 == Changelog == 62 63 = 1.0.19 = 64 * tested wordpress 6.4.3 65 * accounting regions can now be edited by the admin through the menu 66 * a tag system has been implemented 67 * tags can be created through the stand-alone menu called "Tags" and applied to every client profile 68 * client list can be filtered by tags now 69 * open tasks dashboard widget now shows in two columns and can be filtered by due, started and all open tasks 62 70 63 71 = 1.0.18 = -
wp-easy-crm/trunk/views/addClient.php
r3024884 r3033873 10 10 $id = sanitize_text_field(isset($_GET['id']) ? intval($_GET['id']) : ""); 11 11 12 13 14 15 12 if(isset($_POST['btnsubmit'])){ 16 13 … … 19 16 20 17 if(!empty($action)){ 21 //update client 22 $wpdb->update($clientTable,array( 23 "clientname" => sanitize_text_field(wp_unslash($_POST['clientname'])), 24 "clientstatus" => sanitize_text_field(wp_unslash($_POST['clientstatus'])), 25 "email" => sanitize_text_field(wp_unslash($_POST['email'])), 26 "nombrecontacto" => sanitize_text_field(wp_unslash($_POST['nombrecontacto'])), 27 "nota" => sanitize_text_field(wp_unslash($_POST['nota'])), 28 "telefono" => sanitize_text_field(wp_unslash($_POST['telefono'])), 29 "clientsource" => sanitize_text_field(wp_unslash($_POST['clientsource'])), 30 "provincia" => sanitize_text_field(wp_unslash($_POST['provincia'])), 31 "direccion" => sanitize_text_field(wp_unslash($_POST['direccion'])), 32 "lastupdate_at" => sanitize_text_field(wp_unslash($_POST['lastupdate_at'])), 33 "idaccountingregionfk" => sanitize_text_field(wp_unslash($_POST['idaccountingregionfk'])), 34 "created_at" => sanitize_text_field(wp_unslash($_POST['created_at'])) 35 ), array( 36 "id" => $id 37 )); 38 $msg = "<div class='updated update'>" . __( 'Client successfully updated. You will be redirected to the client profile in 2 seconds automatically.', 'wp-easy-crm' ) . "</div>"; 39 40 // Construct the redirect URL dynamically to client profile 41 $redirect_url = admin_url('admin.php?page=wp-easy-crm-perfil&id=' . $id); 42 43 // JavaScript for delay and redirection 44 echo "<script> 45 setTimeout(function() { 46 window.location.href = '" . $redirect_url . "'; 47 }, 2000); 48 </script>"; 49 18 // Update client 19 20 // Fetch existing emails associated with the client being updated 21 $existing_emails_for_client = $wpdb->get_var( 22 $wpdb->prepare( 23 "SELECT email FROM $clientTable WHERE id = %d", $id 24 ) 25 ); 26 27 // Split existing emails into an array 28 $existing_emails_for_client = explode(',', $existing_emails_for_client); 29 30 // Initialize an array to store new emails for the client 31 $new_emails = array(); 32 33 // Retrieve entered emails and split them by comma 34 $entered_emails = isset($_POST['email']) ? sanitize_text_field($_POST['email']) : ''; 35 $emails_array = explode(',', $entered_emails); 36 $existing_emails = array(); 37 38 // Check each email against the database, excluding the current client being updated 39 foreach ($emails_array as $email) { 40 // Trim the email 41 $trimmed_email = trim($email); 42 43 // Check if the trimmed email is not empty 44 if (!empty($trimmed_email)) { 45 // If the email is not associated with the client being updated 46 if (!in_array($trimmed_email, $existing_emails_for_client)) { 47 // Add it to the new emails array for further processing 48 $new_emails[] = $trimmed_email; 49 } 50 } 51 } 52 53 // Initialize an array to store existing emails for other clients 54 $existing_emails = array(); 55 56 // Check each new email against the database for duplication 57 foreach ($new_emails as $new_email) { 58 // Split the new email into an array in case it contains multiple emails 59 $new_email_array = explode(',', $new_email); 60 61 // Check each individual email 62 foreach ($new_email_array as $individual_email) { 63 // If the email already exists for another client 64 $existing_client = $wpdb->get_row( 65 $wpdb->prepare( 66 "SELECT * FROM $clientTable WHERE email LIKE %s AND id != %d", '%' . trim($individual_email) . '%', $id 67 ), ARRAY_A 68 ); 69 70 // If an existing client is found, add the email to the existing emails array 71 if ($existing_client) { 72 $existing_emails[] = trim($individual_email); 73 } 74 } 75 } 76 77 // If there are existing emails, display an alert 78 if (!empty($existing_emails)) { 79 $msg = "<div style='color:red'>".esc_html(__( 'Error - the following email(s) already exist in the database for other clients: ', 'wp-easy-crm' )); 80 foreach ($existing_emails as $existing_email) { 81 $msg .= $existing_email . ', '; 82 } 83 $msg = rtrim($msg, ', '); // Remove trailing comma 84 $msg .= ". Please search for those emails in the client-list and add your data to the existing client files.</div>"; 85 } else { 86 // Continue updating the client 87 $wpdb->update($clientTable,array( 88 "clientname" => sanitize_text_field(wp_unslash($_POST['clientname'])), 89 "clientstatus" => sanitize_text_field(wp_unslash($_POST['clientstatus'])), 90 "email" => sanitize_text_field(wp_unslash($_POST['email'])), 91 "nombrecontacto" => sanitize_text_field(wp_unslash($_POST['nombrecontacto'])), 92 "nota" => sanitize_text_field(wp_unslash($_POST['nota'])), 93 "telefono" => sanitize_text_field(wp_unslash($_POST['telefono'])), 94 "clientsource" => sanitize_text_field(wp_unslash($_POST['clientsource'])), 95 "provincia" => sanitize_text_field(wp_unslash($_POST['provincia'])), 96 "direccion" => sanitize_text_field(wp_unslash($_POST['direccion'])), 97 "lastupdate_at" => sanitize_text_field(wp_unslash($_POST['lastupdate_at'])), 98 "idaccountingregionfk" => sanitize_text_field(wp_unslash($_POST['idaccountingregionfk'])), 99 "created_at" => sanitize_text_field(wp_unslash($_POST['created_at'])) 100 ), array( 101 "id" => $id 102 )); 103 $msg = "<div class='updated update'>" . __( 'Client successfully updated. You will be redirected to the client profile in 2 seconds automatically.', 'wp-easy-crm' ) . "</div>"; 104 105 // Construct the redirect URL dynamically to client profile 106 $redirect_url = admin_url('admin.php?page=wp-easy-crm-perfil&id=' . $id); 107 108 // JavaScript for delay and redirection 109 echo "<script> 110 setTimeout(function() { 111 window.location.href = '" . $redirect_url . "'; 112 }, 2000); 113 </script>"; 114 } 115 116 } else { 117 // Add new client 118 119 // Retrieve entered emails and split them by comma 120 $entered_emails = isset($_POST['email']) ? sanitize_text_field($_POST['email']) : ''; 121 $emails_array = explode(',', $entered_emails); 122 $existing_emails = array(); 123 124 // Check each email against the database 125 foreach ($emails_array as $email) { 126 $existing_client = $wpdb->get_row( 127 $wpdb->prepare( 128 "SELECT * FROM $clientTable WHERE email = %s", trim($email) 129 ), ARRAY_A 130 ); 131 if ($existing_client) { 132 $existing_emails[] = $email; 133 } 134 } 135 136 // If there are existing emails, display an alert 137 if (!empty($existing_emails)) { 138 $msg = "<div style='color:red'>".esc_html(__( 'Error - the following email(s) already exist in the database: ', 'wp-easy-crm' )); 139 foreach ($existing_emails as $existing_email) { 140 $msg .= $existing_email . ', '; 141 } 142 $msg = rtrim($msg, ', '); // Remove trailing comma 143 $msg .= ". Please search for that email in the client-list and add your data to the existing client file.</div>"; 144 } else { 145 // Continue adding the new client 146 $wpdb->insert($clientTable,array( 147 "clientname"=>sanitize_text_field($_POST['clientname']), 148 "clientstatus"=>sanitize_text_field($_POST['clientstatus']), 149 "email"=>sanitize_text_field($_POST['email']), 150 "nombrecontacto"=>sanitize_text_field($_POST['nombrecontacto']), 151 "nota"=>sanitize_text_field($_POST['nota']), 152 "telefono"=>sanitize_text_field($_POST['telefono']), 153 "clientsource"=>sanitize_text_field($_POST['clientsource']), 154 "provincia"=>sanitize_text_field($_POST['provincia']), 155 "direccion"=>sanitize_text_field($_POST['direccion']), 156 "lastupdate_at"=>sanitize_text_field($_POST['lastupdate_at']), 157 "idaccountingregionfk" => sanitize_text_field(wp_unslash($_POST['idaccountingregionfk'])), 158 "created_at"=>sanitize_text_field($_POST['created_at']) 159 )); 160 if($wpdb->insert_id > 0){ 161 $msg = "<div class='updated update'>".esc_html(__( 'client successfully saved. You will be redirected to the client profile in 2 seconds automatically.', 'wp-easy-crm' ))."</div>"; 162 163 // Construct the redirect URL dynamically to client profile 164 $redirect_url = admin_url('admin.php?page=wp-easy-crm-perfil&id=' . $wpdb->insert_id); 165 166 // JavaScript for delay and redirection 167 echo "<script> 168 setTimeout(function() { 169 window.location.href = '" . $redirect_url . "'; 170 }, 2000); 171 </script>"; 172 173 }else{ 174 $msg = "<div style='color:red'>".esc_html(__( 'error - client information couldn\'t be stored', 'wp-easy-crm' ))."</div>"; 175 } 176 } 50 177 } 51 else{52 //add new client53 $wpdb->insert($clientTable,array(54 "clientname"=>sanitize_text_field($_POST['clientname']),55 "clientstatus"=>sanitize_text_field($_POST['clientstatus']),56 "email"=>sanitize_text_field($_POST['email']),57 "nombrecontacto"=>sanitize_text_field($_POST['nombrecontacto']),58 "nota"=>sanitize_text_field($_POST['nota']),59 "telefono"=>sanitize_text_field($_POST['telefono']),60 "clientsource"=>sanitize_text_field($_POST['clientsource']),61 "provincia"=>sanitize_text_field($_POST['provincia']),62 "direccion"=>sanitize_text_field($_POST['direccion']),63 "lastupdate_at"=>sanitize_text_field($_POST['lastupdate_at']),64 "idaccountingregionfk" => sanitize_text_field(wp_unslash($_POST['idaccountingregionfk'])),65 "created_at"=>sanitize_text_field($_POST['created_at'])66 ));67 if($wpdb->insert_id > 0){68 $msg = "<div class='updated update'>".esc_html(__( 'client successfully saved', 'wp-easy-crm' ))."</div>";69 70 }else{71 $msg = "<div style='color:red'>".esc_html(__( 'error - client information couldn\'t be stored', 'wp-easy-crm' ))."</div>";72 }73 74 75 }76 77 78 79 178 } 80 179 … … 84 183 ),ARRAY_A 85 184 ); 86 87 88 185 89 186 ?> … … 112 209 <select name="clientstatus" required> 113 210 <option value="<?php echo esc_html(isset($row_details['clientstatus']) ? $row_details['clientstatus'] : ""); ?>"><?php echo esc_html(isset($row_details['clientstatus']) ? $row_details['clientstatus'] : _e( 'Choose client status', 'wp-easy-crm' ))?></option> 114 <option value="lead"> "<?php _e( "Lead", 'wp-easy-crm' );?>"</option>115 <option value="customer"> "<?php _e( 'Customer', 'wp-easy-crm' );?>"</option>116 <option value="refused"> "<?php _e( 'Refused', 'wp-easy-crm' );?>"</option>117 <option value="blacklisted"> "<?php _e( 'Blacklisted', 'wp-easy-crm' );?>"</option>211 <option value="lead"><?php _e( "Lead", 'wp-easy-crm' );?></option> 212 <option value="customer"><?php _e( 'Customer', 'wp-easy-crm' );?></option> 213 <option value="refused"><?php _e( 'Refused', 'wp-easy-crm' );?></option> 214 <option value="blacklisted"><?php _e( 'Blacklisted', 'wp-easy-crm' );?></option> 118 215 119 216 </select> … … 128 225 <select name="clientsource" required> 129 226 <option value="<?php echo esc_html(isset($row_details['clientsource']) ? $row_details['clientsource'] : ""); ?>"><?php echo esc_html(isset($row_details['clientsource']) ? $row_details['clientsource'] : _e( 'Choose client source', 'wp-easy-crm' ))?></option> 130 <option value="website"> "<?php _e( "Website", 'wp-easy-crm' );?>"</option>131 <option value="email"> "<?php _e( 'Email', 'wp-easy-crm' );?>"</option>132 <option value="call"> "<?php _e( 'Call', 'wp-easy-crm' );?>"</option>133 <option value="social media"> "<?php _e( 'Social Media', 'wp-easy-crm' );?>"</option>134 <option value="recommendation"> "<?php _e( 'Recommendation', 'wp-easy-crm' );?>"</option>135 <option value="other"> "<?php _e( 'Other', 'wp-easy-crm' );?>"</option>227 <option value="website"><?php _e( "Website", 'wp-easy-crm' );?></option> 228 <option value="email"><?php _e( 'Email', 'wp-easy-crm' );?></option> 229 <option value="call"><?php _e( 'Call', 'wp-easy-crm' );?></option> 230 <option value="social media"><?php _e( 'Social Media', 'wp-easy-crm' );?></option> 231 <option value="recommendation"><?php _e( 'Recommendation', 'wp-easy-crm' );?></option> 232 <option value="other"><?php _e( 'Other', 'wp-easy-crm' );?></option> 136 233 </select> 137 234 … … 203 300 204 301 </form> 205 206 -
wp-easy-crm/trunk/views/addTask.php
r3031193 r3033873 125 125 $taskdescription = wpautop($_POST['taskdescription']); 126 126 127 $row_details_client = $wpdb->get_row( 128 $wpdb->prepare( 129 "SELECT * from $clientTable WHERE id = %d",$id 130 ),ARRAY_A 131 ); 132 127 133 128 134 if(!empty($action)){ … … 172 178 $user_data = get_userdata(sanitize_text_field($_POST['useridfk'])); 173 179 $to = $user_data->user_email; 174 $subject = __('A task was edited for you', 'wp-easy-crm' ); 180 if (isset($row_details_client['clientname']) && is_string($row_details_client['clientname'])) { 181 // $row_details_client is not empty, process the data 182 $subject = __('A task was edited for you for client: ', 'wp-easy-crm' ).$row_details_client['clientname']; 183 } else { 184 // $row_details_client is empty, handle the case where no data was found 185 $subject = __('A task was edited for you', 'wp-easy-crm' ); 186 } 175 187 $message = __('The Task Title is: ', 'wp-easy-crm') .sanitize_text_field($_POST['tasktitle']); 176 188 $headers = array('From: Easy CRM '.esc_html($domain_name).' <wordpress@'.esc_html($domain_name).'>', 'Content-Type: text/html; charset=UTF-8'); … … 185 197 else{ 186 198 // Allowed HTML tags and attributes 187 188 189 199 190 200 191 201 $taskdescription = wpautop($_POST['taskdescription']); … … 223 233 $user_data = get_userdata($_POST['useridfk']); 224 234 $to = $user_data->user_email; 225 $subject = __('A new task was added for you', 'wp-easy-crm' ); 235 if (isset($row_details_client['clientname']) && is_string($row_details_client['clientname'])) { 236 // $row_details_client is not empty, process the data 237 $subject = __('A new task was added for you for client: ', 'wp-easy-crm' ).$row_details_client['clientname']; 238 } else { 239 // $row_details_client is empty, handle the case where no data was found 240 $subject = __('A new task was added for you', 'wp-easy-crm' ); 241 } 242 226 243 $message = __('The Task Title is: ', 'wp-easy-crm') .sanitize_text_field($_POST['tasktitle']); 227 244 $headers = array('From: Easy CRM '.esc_html($domain_name).' <wordpress@'.esc_html($domain_name).'>', 'Content-Type: text/html; charset=UTF-8'); -
wp-easy-crm/trunk/views/clientProfile.php
r3031193 r3033873 153 153 ?> <b><?php _e( 'Contact(s):', 'wp-easy-crm' );?></b> <?php echo esc_html($row_details['nombrecontacto']) ?> <b>Email(s):</b> <?php echo esc_html($row_details['email']) ?> <b><?php _e( 'Telephone(s):', 'wp-easy-crm' );?></b> <?php echo $row_details['telefono'] ?> <b><?php _e( 'State:', 'wp-easy-crm' );?></b> <?php echo $row_details['provincia'] ?></code> 154 154 </br></br><code><b><?php _e( 'Address:', 'wp-easy-crm' );?></b> <?php echo esc_html($row_details['direccion']) ?> <b>Accounting Region:</b> <?php echo esc_html($accountingRegionName) ?> </code> 155 </br></br><code><b><?php _e( 'Note:', 'wp-easy-crm' );?></b> <?php echo esc_html($row_details['nota']) ?></code> 155 </br></br><code><b><?php _e( 'Note:', 'wp-easy-crm' );?></b> <?php echo esc_html($row_details['nota']) ?></code><br/><br/> 156 <b> <?php _e( 'Tags: ', 'wp-easy-crm' );?></b><?php echoTagsStuff($row_details); //add tags menu and pass client data ?> 156 157 157 158 <style> … … 469 470 </script> 470 471 472 <?php 473 474 //this section echos all the hashtag section in the client profile menu 475 function echoTagsStuff($clientdata) { 476 global $wpdb; 477 $tagTable = $wpdb->prefix . 'easytags'; 478 $clientTable = $wpdb->prefix . 'clients'; 479 $clientId = isset($clientdata['id']) ? $clientdata['id'] : 0; 480 $currentTagsIds = !empty($clientdata['tagsrelations']) ? explode(',', $clientdata['tagsrelations']) : []; 481 482 // Handle tag deletion 483 if (isset($_POST['delete_tag'], $_POST['tag_id'], $_POST['_wpnonce_delete_tag']) && wp_verify_nonce($_POST['_wpnonce_delete_tag'], 'delete_tag_action')) { 484 $tagIdToDelete = intval($_POST['tag_id']); 485 if (($key = array_search($tagIdToDelete, $currentTagsIds)) !== false) { 486 unset($currentTagsIds[$key]); 487 $newTagsIds = implode(',', $currentTagsIds); 488 $wpdb->update($clientTable, ['tagsrelations' => $newTagsIds], ['id' => $clientId]); 489 echo "<script>window.location.reload();</script>"; 490 } 491 } 492 493 // Handle adding a new tag 494 if (isset($_POST['add_tag'], $_POST['new_tag_id'], $_POST['_wpnonce_add_new_tag']) && wp_verify_nonce($_POST['_wpnonce_add_new_tag'], 'add_new_tag_action')) { 495 $newTagId = intval($_POST['new_tag_id']); 496 if (!in_array($newTagId, $currentTagsIds)) { 497 $currentTagsIds[] = $newTagId; 498 $newTagsIds = implode(',', $currentTagsIds); 499 $wpdb->update($clientTable, ['tagsrelations' => $newTagsIds], ['id' => $clientId]); 500 echo "<script>window.location.reload();</script>"; 501 } 502 } 503 504 // Fetch and display current tags 505 if (!empty($currentTagsIds)) { 506 $placeholders = implode(',', array_fill(0, count($currentTagsIds), '%d')); 507 $tags = $wpdb->get_results($wpdb->prepare("SELECT id, tagtitle, tagcolor FROM $tagTable WHERE id IN ($placeholders)", $currentTagsIds)); 508 foreach ($tags as $tag) { 509 echo '<div class="tag-bubble" style="background-color:' . esc_attr($tag->tagcolor) . '; color: #ffffff;">'; 510 echo '#' . esc_html($tag->tagtitle); 511 echo '<form method="post" action="" style="display:inline;"><input type="hidden" name="tag_id" value="' . esc_attr($tag->id) . '"><input type="hidden" name="delete_tag" value="1"><input type="hidden" name="_wpnonce_delete_tag" value="' . wp_create_nonce('delete_tag_action') . '"><button type="submit" class="tag-delete">X</button></form>'; 512 echo '</div>'; 513 } 514 } 515 516 // Collapsible Add Tag Form 517 echo '<div id="addTagButton" style="cursor: pointer; display: inline-block; margin-left: 20px; font-size: 24px;">+</div>'; 518 echo '<div id="addTagForm" style="display: none; margin-top: 10px;">'; 519 echo '<form method="post" action="">'; 520 echo '<select name="new_tag_id"><option value="">Select a tag to add</option>'; 521 $allTags = $wpdb->get_results("SELECT id, tagtitle FROM $tagTable"); 522 foreach ($allTags as $tag) { 523 if (!in_array($tag->id, $currentTagsIds)) { 524 echo '<option value="' . esc_attr($tag->id) . '">' . esc_html($tag->tagtitle) . '</option>'; 525 } 526 } 527 echo '</select>'; 528 echo '<input type="hidden" name="add_tag" value="1">'; 529 echo wp_nonce_field('add_new_tag_action', '_wpnonce_add_new_tag', true, false); 530 echo '<input type="submit" value="Add Tag">'; 531 echo '</form></div>'; 532 533 // JavaScript for collapsible form 534 echo '<script> 535 jQuery(document).ready(function($) { 536 $("#addTagButton").click(function() { 537 $("#addTagForm").slideToggle(); 538 }); 539 }); 540 </script>'; 541 542 // Styling 543 echo '<style> 544 .tag-bubble { 545 display: inline-block; 546 border-radius: 15px; 547 padding: 5px 10px; 548 margin: 5px; 549 cursor: pointer; 550 font-weight: bold; 551 background-color: #ffffff; 552 color: #ffffff; 553 box-shadow: 0 2px 4px rgba(0,0,0,0.2); 554 letter-spacing: 2px; /* Increased letter spacing */ 555 } 556 .tag-delete { 557 margin-left: 8px; 558 color: #000000; 559 cursor: pointer; 560 } 561 #addTagButton { 562 background-color: #f0f0f0; 563 padding: 8px; /* Reduced padding for a smaller circle */ 564 border-radius: 50%; 565 width: 24px; /* Reduced width for a smaller circle */ 566 height: 24px; /* Reduced height for a smaller circle */ 567 text-align: center; 568 line-height: 8px; /* Adjust line height for vertical alignment */ 569 box-shadow: 0 2px 4px rgba(0,0,0,0.2); 570 cursor: pointer; 571 } 572 #addTagForm select, #addTagForm input[type="submit"] { 573 margin-top: 5px; 574 } 575 </style>'; 576 } 577 578 579 580 581 582 583 584 585 ?> 586 471 587 <!-- Hook for Projects and other modules to be added --> 472 588 <?php -
wp-easy-crm/trunk/views/listClients.php
r3031193 r3033873 11 11 $accregionTable = $wpdb->prefix . 'eacraccountingregion'; 12 12 $projectsTable = $wpdb->prefix . 'easyprojects'; 13 $tagTable = $wpdb->prefix . 'easytags'; 13 14 14 15 … … 184 185 // echo "Table with clients does not exist."; 185 186 } 187 } 188 189 190 // Assuming $tagTable is defined and contains the name of your tag table 191 $allTags = $wpdb->get_results("SELECT * FROM $tagTable ORDER BY tagtitle ASC"); 192 $tagMap = []; 193 foreach ($allTags as $tag) { 194 // Assuming $tag->id, $tag->tagtitle, and $tag->tagcolor are the properties 195 $tagMap[$tag->id] = $tag; 186 196 } 187 197 … … 300 310 // Initialize your DataTable 301 311 var table = $('#clientstable').DataTable({ 302 order: [[ 7, 'desc']],312 order: [[8, 'desc']], 303 313 "pageLength": 12, // Default number of rows to display 304 314 "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], // Page length options (including 'All') … … 310 320 }, 311 321 { 312 "targets": 8, // Index of the 9th column (Region ID)322 "targets": 9, // Index of the 9th column (Region ID) 313 323 "visible": false // Hide the column 314 324 } … … 360 370 } else { 361 371 // Filter DataTables rows based on the region ID 362 // Assumes the region ID is in a specific column (e.g., column index 8)363 table.column( 8).search(regionId).draw();372 // Assumes the region ID is in a specific column (e.g., column index 9) 373 table.column(9).search(regionId).draw(); 364 374 } 365 375 }); 366 376 377 jQuery('#filterbytags').click(function(e) { 378 e.preventDefault(); 379 jQuery(this).toggleClass('show-menu'); 380 jQuery('#tagFilterContainer').slideToggle(); 381 382 367 383 }); 384 385 // Filter button click event handler 386 jQuery('#applyTagFilter').click(function() { 387 // Get an array of selected tag IDs 388 var selectedTags = jQuery('input[name="tags[]"]:checked').map(function() { 389 return jQuery(this).val(); 390 }).get(); 391 392 // Clear any previous custom search function 393 jQuery.fn.dataTable.ext.search = []; 394 395 if (selectedTags.length > 0) { 396 // Use custom filtering function to check if any of the selected tags match the tags associated with each row 397 jQuery.fn.dataTable.ext.search.push( 398 function(settings, data, dataIndex) { 399 var rowTags = jQuery(table.row(dataIndex).node()).find('.column-columnname span[data-tagid]').map(function() { 400 return jQuery(this).data('tagid').toString(); 401 }).get(); 402 403 return selectedTags.every(function(tag) { 404 return rowTags.includes(tag); 405 }); 406 } 407 ); 408 } 409 410 table.draw(); // Redraw table to apply search/filter 411 412 //jQuery('#tagFilterContainer').slideUp(); // Hide the tag filter container 413 }); 414 415 416 417 418 }); 419 420 421 368 422 369 423 </script> … … 380 434 <a class="button button-secondary" id="buttonclientsonly" href=""><?php _e( 'Show Clients only', 'wp-easy-crm' );?></a> 381 435 <a class="button button-secondary" id="buttonblackrefonly" href=""><?php _e( 'Show Refused and Blacklisted only', 'wp-easy-crm' );?></a> 436 <style>#tagFilterContainer { 437 padding: 10px; 438 border: 1px solid #ccc; 439 margin-top: 10px; 440 } 441 #filterbytags::after { 442 content: '\25BC'; /* Unicode character for down-pointing triangle */ 443 } 444 445 #filterbytags.show-menu::after { 446 content: '\25B2'; /* Unicode character for up-pointing triangle */ 447 } 448 449 </style> 450 <a class="button button-secondary" id="filterbytags" href=""><?php _e( 'Filter by Tags', 'wp-easy-crm' );?></a> 451 <div id="tagFilterContainer" style="display:none;"> 452 <span>Those filters will persist until the page is reloaded. Uncheck all and click 'Filter' again to show all entries.</span> 453 <form id="tagFilterForm" style="display: flex; flex-wrap: wrap; align-items: center; padding: 10px;"> 454 <?php foreach ($allTags as $tag): ?> 455 <label style="margin: 5px; padding: 5px; background-color: <?php echo esc_attr($tag->tagcolor); ?>; color: #ffffff; border-radius: 5px; display: flex; align-items: center;"> 456 <input type="checkbox" name="tags[]" value="<?php echo esc_attr($tag->id); ?>" style="margin-right: 5px;" /> 457 <?php echo esc_html($tag->tagtitle); ?> 458 </label> 459 <?php endforeach; ?> 460 <button type="button" class="button-primary" id="applyTagFilter" style="margin-left: auto; padding: 5px 10px; cursor: pointer;"><?php _e('Filter', 'wp-easy-crm'); ?></button> 461 </form> 462 </div> 463 382 464 <?php 383 465 // if general access list buttons to filter by country / accounting region … … 457 539 <th class="manage-column column-cb check-column" scope="col"><b><?php _e( 'Contacts', 'wp-easy-crm' );?></b></th> 458 540 <th class="manage-column column-cb check-column" scope="col"><b><?php _e( 'Telephone', 'wp-easy-crm' );?></b></th> 541 <th class="manage-column column-cb check-column" scope="col"><b><?php _e( 'Tags', 'wp-easy-crm' );?></b></th> 459 542 <th class="manage-column column-cb check-column" scope="col"><b><?php _e( 'Date added', 'wp-easy-crm' );?></b></th> 460 543 <th class="manage-column column-cb check-column" scope="col"><b><?php _e( 'Region ID', 'wp-easy-crm' );?></b></th> … … 551 634 <td class="column-columnname"><?php echo esc_html($client['nombrecontacto']) ?></td> 552 635 <td class="column-columnname"><?php echo esc_html($client['telefono']) ?></td> 636 <td class="column-columnname"> 637 <?php 638 // Split the client's tag relations into an array of tag IDs 639 $clientTagIds = explode(',', $client['tagsrelations']); 640 641 foreach ($clientTagIds as $tagId) { 642 // Check if the tag ID exists in the tag map 643 if (isset($tagMap[$tagId])) { 644 // Display the tag title in its defined color 645 $tag = $tagMap[$tagId]; 646 echo '<span data-tagid="' . esc_attr($tag->id) . '" style="background-color: ' . esc_attr($tag->tagcolor) . '; color: #ffffff; padding: 2px 5px; border-radius: 3px; margin-right: 5px;">' . esc_html($tag->tagtitle) . '</span>'; 647 } 648 } 649 ?> 650 </td> 651 652 553 653 <td class="column-columnname"><?php echo esc_html($client['created_at']) ?></td> 554 654 <td class="column-columnname"><?php echo esc_html($client['idaccountingregionfk']) ?></td>
Note: See TracChangeset
for help on using the changeset viewer.