diff --git a/README.md b/README.md index a9cc5dab..3e305261 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,8 @@ ITFlow is self-hosted. There is a full installation guide in the [docs](https:// - Login as root - Download & run install script ``` - wget -O - https://github.com/itflow-org/itflow-install-script/raw/main/itflow_install.sh | bash + wget -O itflow_install.sh https://github.com/itflow-org/itflow-install-script/raw/main/itflow_install.sh + bash itflow_install.sh ``` - Follow Instructions & navigate to setup URL shown - Leave us feedback in the [forum](https://forum.itflow.org/d/11-road-map) diff --git a/client_add_modal.php b/client_add_modal.php index 473949c7..324d8f7a 100644 --- a/client_add_modal.php +++ b/client_add_modal.php @@ -2,12 +2,15 @@ + +
+
@@ -93,7 +128,9 @@
- +
@@ -105,8 +142,12 @@ @@ -120,8 +161,12 @@ @@ -133,12 +178,17 @@
- + - + @@ -147,7 +197,8 @@
- +
@@ -175,10 +226,16 @@ ?>
  • - " name="tags[]" value="" > -
    @@ -188,7 +245,7 @@ - +
    @@ -203,10 +260,12 @@
    - + \ No newline at end of file diff --git a/client_leads.php b/client_leads.php new file mode 100644 index 00000000..4817a7d1 --- /dev/null +++ b/client_leads.php @@ -0,0 +1,301 @@ + + +
    +
    +

    Lead Management

    +
    + + + +
    +
    + +
    +
    +
    +
    +
    + +
    + + +
    +
    +
    +
    +
    + +
    +
    +
    +
    " id="advancedFilter"> +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    +
    +
    + + "> + + + + + + + + + $location_city $location_state $location_zip"; + } + $contact_id = intval($row['contact_id']); + $contact_name = nullable_htmlentities($row['contact_name']); + $contact_title = nullable_htmlentities($row['contact_title']); + $contact_phone = formatPhoneNumber($row['contact_phone']); + $contact_extension = nullable_htmlentities($row['contact_extension']); + $contact_mobile = formatPhoneNumber($row['contact_mobile']); + $contact_email = nullable_htmlentities($row['contact_email']); + $client_website = nullable_htmlentities($row['client_website']); + $client_rate = floatval($row['client_rate']); + $client_currency_code = nullable_htmlentities($row['client_currency_code']); + $client_net_terms = intval($row['client_net_terms']); + $client_tax_id_number = nullable_htmlentities($row['client_tax_id_number']); + $client_referral = nullable_htmlentities($row['client_referral']); + $client_notes = nullable_htmlentities($row['client_notes']); + $client_created_at = date('Y-m-d', strtotime($row['client_created_at'])); + $client_updated_at = nullable_htmlentities($row['client_updated_at']); + $client_archive_at = nullable_htmlentities($row['client_archived_at']); + $client_is_lead = intval($row['client_lead']); + + // Client Tags + + $client_tag_name_display_array = array(); + $client_tag_id_array = array(); + $sql_client_tags = mysqli_query($mysqli, "SELECT * FROM client_tags LEFT JOIN tags ON client_tags.client_tag_tag_id = tags.tag_id WHERE client_tags.client_tag_client_id = $client_id ORDER BY tag_name ASC"); + while ($row = mysqli_fetch_array($sql_client_tags)) { + + $client_tag_id = intval($row['tag_id']); + $client_tag_name = nullable_htmlentities($row['tag_name']); + $client_tag_color = nullable_htmlentities($row['tag_color']); + if (empty($client_tag_color)) { + $client_tag_color = "dark"; + } + $client_tag_icon = nullable_htmlentities($row['tag_icon']); + if (empty($client_tag_icon)) { + $client_tag_icon = "tag"; + } + + $client_tag_id_array[] = $client_tag_id; + $client_tag_name_display_array[] = "$client_tag_name "; + } + $client_tags_display = implode('', $client_tag_name_display_array); + + //Add up all the payments for the invoice and get the total amount paid to the invoice + $sql_invoice_amounts = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE invoice_client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' "); + $row = mysqli_fetch_array($sql_invoice_amounts); + + $invoice_amounts = floatval($row['invoice_amounts']); + + $sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_client_id = $client_id"); + $row = mysqli_fetch_array($sql_amount_paid); + + $amount_paid = floatval($row['amount_paid']); + + $balance = $invoice_amounts - $amount_paid; + //set Text color on balance + if ($balance > 0) { + $balance_text_color = "text-danger font-weight-bold"; + } else { + $balance_text_color = ""; + } + + //Get Monthly Recurring Total + $sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND recurring_client_id = $client_id"); + $row = mysqli_fetch_array($sql_recurring_monthly_total); + + $recurring_monthly_total = floatval($row['recurring_monthly_total']); + + //Get Yearly Recurring Total + $sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND recurring_client_id = $client_id"); + $row = mysqli_fetch_array($sql_recurring_yearly_total); + + $recurring_yearly_total = floatval($row['recurring_yearly_total']) / 12; + + $recurring_monthly = $recurring_monthly_total + $recurring_yearly_total; + + ?> + + + + + + + + + + + + + + +
    NamePrimary address Primary contact Action
    + + + +
    + +
    + + +
    + +
    + +
    + Created: +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    + +
    +
    + + CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.3.1'"); } - if (CURRENT_DATABASE_VERSION == '0.3.1') { // Assets @@ -1104,8 +1103,6 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.5.9'"); } - - if (CURRENT_DATABASE_VERSION == '0.5.9') { // Copy primary_location and primary_contact to their new vars in their own respecting tables @@ -1374,7 +1371,6 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.6'"); } - // Update DB to 0.8.7 if (CURRENT_DATABASE_VERSION == '0.8.6') { // Insert queries here required to update to DB version 0.8.7 mysqli_query($mysqli, "ALTER TABLE `accounts` ADD `account_type` int(6) DEFAULT NULL AFTER `account_notes`"); @@ -1384,7 +1380,6 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.7'"); } - // Update DB to 0.8.8 if (CURRENT_DATABASE_VERSION == '0.8.7') { //Create Main Account Types mysqli_query($mysqli,"INSERT INTO account_types SET account_type_name = 'Asset', account_type_id= '10', account_type_description = 'Assets are economic resources which are expected to benefit the business in the future.'"); @@ -1401,10 +1396,7 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.8'"); } - // Be sure to change database_version.php to reflect the version you are updating to here - // Please add this same comment block to the bottom of this file, and update the version number. - // Uncomment Below Lines, to add additional database updates - // + if (CURRENT_DATABASE_VERSION == '0.8.8') { // Insert queries here required to update to DB version 0.8.9 mysqli_query($mysqli, "ALTER TABLE `invoice_items` ADD `item_order` INT(11) NOT NULL DEFAULT 0 AFTER `item_total`"); @@ -1430,10 +1422,7 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { } // - // Be sure to change database_version.php to reflect the version you are updating to here - // Please add this same comment block to the bottom of this file, and update the version number. - // Uncomment Below Lines, to add additional database updates - // + if (CURRENT_DATABASE_VERSION == '0.8.9') { // Insert queries here required to update to DB version 0.9.0 // Update existing quotes and recurrings so that item_order is set to item_id @@ -1483,6 +1472,24 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { } + // Be sure to change database_version.php to reflect the version you are updating to here + // Please add this same comment block to the bottom of this file, and update the version number. + // Uncomment Below Lines, to add additional database updates + // + if (CURRENT_DATABASE_VERSION == '0.9.0') { + //add leads column to clients table + mysqli_query($mysqli, "ALTER TABLE `clients` ADD `client_lead` TINYINT(1) NOT NULL DEFAULT 0 AFTER `client_id`"); + + // Then, update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.1'"); + } + + //if (CURRENT_DATABASE_VERSION == '0.9.1') { + // Insert queries here required to update to DB version 0.9.0 + + // Then, update the database to the next sequential version + // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.2'"); + //} } else { // Up-to-date } diff --git a/database_version.php b/database_version.php index e3fd290e..a7270c3d 100644 --- a/database_version.php +++ b/database_version.php @@ -6,3 +6,4 @@ */ DEFINE("LATEST_DATABASE_VERSION", "0.9.2"); + diff --git a/db.sql b/db.sql index 812955d2..b21d0773 100644 --- a/db.sql +++ b/db.sql @@ -275,6 +275,7 @@ DROP TABLE IF EXISTS `clients`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `clients` ( `client_id` int(11) NOT NULL AUTO_INCREMENT, + `client_lead` tinyint(1) NOT NULL DEFAULT 0, `client_name` varchar(200) NOT NULL, `client_type` varchar(200) DEFAULT NULL, `client_website` varchar(200) DEFAULT NULL, diff --git a/post/client.php b/post/client.php index a2b7948a..a99c8c54 100644 --- a/post/client.php +++ b/post/client.php @@ -25,7 +25,7 @@ if (isset($_POST['add_client'])) { $extended_log_description = ''; - mysqli_query($mysqli, "INSERT INTO clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_rate = $rate, client_currency_code = '$currency_code', client_net_terms = $net_terms, client_tax_id_number = '$tax_id_number', client_notes = '$notes', client_accessed_at = NOW()"); + mysqli_query($mysqli, "INSERT INTO clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_rate = $rate, client_currency_code = '$currency_code', client_net_terms = $net_terms, client_tax_id_number = '$tax_id_number', client_lead = '$lead', client_notes = '$notes', client_accessed_at = NOW()"); $client_id = mysqli_insert_id($mysqli); @@ -113,7 +113,7 @@ if (isset($_POST['edit_client'])) { $client_id = intval($_POST['client_id']); - mysqli_query($mysqli, "UPDATE clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_rate = $rate, client_currency_code = '$currency_code', client_net_terms = $net_terms, client_tax_id_number = '$tax_id_number', client_notes = '$notes' WHERE client_id = $client_id"); + mysqli_query($mysqli, "UPDATE clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_rate = $rate, client_currency_code = '$currency_code', client_net_terms = $net_terms, client_tax_id_number = '$tax_id_number', client_lead = '$lead', client_notes = '$notes' WHERE client_id = $client_id"); //Tags //Delete existing tags diff --git a/post/client_model.php b/post/client_model.php index 3095f7b1..05179131 100644 --- a/post/client_model.php +++ b/post/client_model.php @@ -8,3 +8,4 @@ $currency_code = sanitizeInput($_POST['currency_code']); $net_terms = intval($_POST['net_terms']); $tax_id_number = sanitizeInput($_POST['tax_id_number']); $notes = sanitizeInput($_POST['notes']); +$lead = intval($_POST['lead']); diff --git a/setup.php b/setup.php index b7792b4f..45878280 100644 --- a/setup.php +++ b/setup.php @@ -16,7 +16,7 @@ if ($config_enable_setup == 0) { exit; } -include_once("settings_localization_arrays.php"); +include_once("settings_localization_array.php"); // Get a list of all available timezones $timezones = DateTimeZone::listIdentifiers(); diff --git a/side_nav.php b/side_nav.php index 6bf3d75b..eb45d634 100644 --- a/side_nav.php +++ b/side_nav.php @@ -68,6 +68,12 @@ if ($config_module_enable_accounting == 1) { ?>
  • +