Example #1
0
 public function delete()
 {
     if ($this->file_id && module_file::can_i('delete', 'Files')) {
         $file_data = $this->get_data();
         if ($this->can_i_access()) {
             // delete any sub files of buckets first.
             // todo: recurisive testing.
             if ($file_data['bucket']) {
                 $sub_files = module_file::get_files(array('bucket_parent_file_id' => $file_data['file_id']));
                 foreach ($sub_files as $sub_file) {
                     if ($sub_file['file_id'] && $sub_file['bucket_parent_file_id'] == $this->file_id) {
                         $sub_file_ucm = new ucm_file($sub_file['file_id']);
                         $sub_file_ucm->delete();
                     }
                 }
             }
             // delete the physical file.
             if ($file_data['file_path'] && is_file($file_data['file_path'])) {
                 unlink($file_data['file_path']);
             }
             // delete the db entry.
             delete_from_db('file', 'file_id', $this->file_id);
             // delete any comments.
             delete_from_db('file_comment', 'file_id', $this->file_id);
             // delete any staff rel.
             delete_from_db('file_user_rel', 'file_id', $this->file_id);
             // delete any notifications
             delete_from_db('file_notification', 'file_id', $this->file_id);
         }
     }
 }
Example #2
0
    });
}
if (class_exists('module_job', false)) {
    $columns['file_job'] = array('title' => 'Job', 'callback' => function ($file) {
        echo module_job::link_open($file['job_id'], true);
    });
}
if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
    $columns['file_quote'] = array('title' => 'Quote', 'callback' => function ($file) {
        echo module_quote::link_open($file['quote_id'], true);
    });
}
$columns['file_date_added'] = array('title' => 'Date Added', 'callback' => function ($file) {
    echo _l('%s by %s', print_date($file['date_created']), module_user::link_open($file['create_user_id'], true));
});
if (module_file::can_i('edit', 'Files')) {
    $columns['file_action'] = array('title' => ' ', 'callback' => function ($file) {
        echo '<input type="checkbox" name="bulk_operation[' . $file['file_id'] . ']" value="yes">';
    });
}
if (class_exists('module_extra', false)) {
    $table_manager->display_extra('file', function ($file) {
        module_extra::print_table_data('file', $file['file_id']);
    });
}
$table_manager->set_columns($columns);
$table_manager->row_callback = function ($row_data) {
    // load the full file data before displaying each row so we have access to more details
    if (isset($row_data['file_id']) && (int) $row_data['file_id'] > 0) {
        // not needed in this case
        //return module_file::get_file($row_data['file_id']);
                        <th>
                            <?php 
    echo _l('Preview Image');
    ?>
                        </th>
                        <td>
                            <?php 
    if ($newsletter_template['directory'] && is_dir($newsletter_template['directory']) && is_file($newsletter_template['directory'] . 'preview.jpg')) {
        ?>
                                 <img src="<?php 
        echo full_link($newsletter_template['directory'] . 'preview.jpg');
        ?>
">
                                 <?php 
    } else {
        module_file::display_files(array('owner_table' => 'newsletter_template', 'owner_id' => $newsletter_template_id, 'layout' => 'gallery'));
    }
    ?>
                        </td>
                    </tr>
                    <?php 
    if ($newsletter_template['directory'] && is_dir($newsletter_template['directory'])) {
        if (is_file($newsletter_template['directory'] . 'render.php')) {
            $description = 'N/A';
            $contents = file_get_contents($newsletter_template['directory'] . 'render.php');
            if (preg_match('#Description:(.*)#i', $contents, $matches)) {
                $description = htmlspecialchars($matches[1]);
            }
            ?>
                                <tr>
                                    <th>
Example #4
0
 public static function customer_id_changed($old_customer_id, $new_customer_id)
 {
     $old_customer_id = (int) $old_customer_id;
     $new_customer_id = (int) $new_customer_id;
     if ($old_customer_id > 0 && $new_customer_id > 0) {
         $sql = "UPDATE `" . _DB_PREFIX . "job` SET customer_id = " . $new_customer_id . " WHERE customer_id = " . $old_customer_id;
         query($sql);
         module_invoice::customer_id_changed($old_customer_id, $new_customer_id);
         module_file::customer_id_changed($old_customer_id, $new_customer_id);
     }
 }
Example #5
0
		    <a href="<?php 
        echo module_file::link_generate(false, array('arguments' => array('job_id' => $job['job_id']), 'data' => array('job_id' => $job['job_id'])));
        ?>
"><?php 
        echo _l('View all %d files in this job', count($files));
        ?>
</a>
	    <?php 
    } else {
        echo _l("This job has %d files", count($files));
    }
    echo '<br/>';
    ?>

	    <a href="<?php 
    echo module_file::link_generate('new', array('arguments' => array('job_id' => $job['job_id'])));
    ?>
"><?php 
    _e('Add New File');
    ?>
</a>
	    <?php 
    $fieldset_data['elements']['files'] = array('title' => 'Files', 'fields' => array(ob_get_clean()));
}
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
if (module_config::c('job_enable_description', 1)) {
    if (!module_job::can_i('edit', 'Jobs') && !$job['description']) {
        // no description, no ability to edit description, don't show anything.
    } else {
        // can edit description
Example #6
0
        ?>

                <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;">
                    <?php 
        echo $note_text;
        ?>

                    <div style="font-size:10px; text-align:right; color:#CCCCCC;">From <?php 
        echo $item['create_user_id'] ? module_user::link_open($item['create_user_id'], true) : _l('Customer');
        ?>
 on <?php 
        echo print_date($item['date_created'], true);
        ?>

                        <?php 
        if (module_file::can_i('delete', 'File Comments') || $item['create_user_id'] == module_security::get_loggedin_id()) {
            ?>

                        <a href="#" onclick="if(confirm('<?php 
            echo _l('Really remove this comment?');
            ?>
')){$('#delete_file_comment_id').val('<?php 
            echo $item['file_comment_id'];
            ?>
'); $('#butt_save_note').click(); } return false;" style="color:#FF0000">x</a>
                        <?php 
        }
        ?>

                    </div>
                </div>
Example #7
0
                   </td>
               </tr>
           </tbody>
           </table>
       </div> */
    ?>
                                    
                                <?php 
    print_heading(array('type' => 'h3', 'title' => 'Attachments:', 'help' => 'Attachments will be sent out with emails. This will use a LOT of your bandwidth! (eg: a 1MB PDF sent to 1000 people = 1GB)'));
    ?>
                                <table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form">
                                <tbody>
                                    <tr>
                                        <td>
                                            <?php 
    module_file::display_files(array('owner_table' => 'newsletter_files', 'owner_id' => $newsletter_id, 'layout' => 'list'));
    ?>
                                        </td>
                                    </tr>
                                </tbody>
                                </table>

                            <?php 
}
?>

                                <?php 
print_heading(array('type' => 'h3', 'title' => 'Dynamic Fields:', 'button' => array('url' => '#', 'onclick' => "\$('#dynamic_more').show(); return false;", 'title' => 'View All')));
?>
                                <table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tbl_fixed">
                                <tbody>
Example #8
0
 public function external_hook($hook)
 {
     switch ($hook) {
         case 'public_signup_form':
             $signup_form = module_template::get_template_by_key('customer_signup_form_wrapper');
             $signup_form->page_title = $signup_form->description;
             $signup_form->assign_values(array('signup_form' => self::get_customer_signup_form_html()));
             echo $signup_form->render('pretty_html');
             exit;
         case 'public_signup':
             // sign out if testing.
             if (module_security::is_logged_in()) {
                 set_message('Logged out due to signup');
                 module_security::logout();
             }
             $result = array('messages' => array());
             function customer_signup_complete($result)
             {
                 if (isset($_REQUEST['via_ajax'])) {
                     echo json_encode($result);
                 } else {
                     echo implode('<br/>', $result['messages']);
                 }
                 exit;
             }
             if (!module_config::c('customer_signup_allowed', 0)) {
                 $result['error'] = 1;
                 $result['messages'][] = 'Customer signup disabled';
                 customer_signup_complete($result);
             }
             //recaptcha on signup form.
             if (module_config::c('captcha_on_signup_form', 0)) {
                 if (!module_captcha::check_captcha_form()) {
                     $result['error'] = 1;
                     $result['messages'][] = 'Captcha fail, please go back and enter correct captcha code.';
                     customer_signup_complete($result);
                 }
             }
             $customer = isset($_POST['customer']) && is_array($_POST['customer']) ? $_POST['customer'] : array();
             $contact = isset($_POST['contact']) && is_array($_POST['contact']) ? $_POST['contact'] : array();
             $contact_extra = isset($contact['extra']) && is_array($contact['extra']) ? $contact['extra'] : array();
             $contact_group = isset($contact['group_ids']) && is_array($contact['group_ids']) ? $contact['group_ids'] : array();
             $customer_extra = isset($customer['extra']) ? $customer['extra'] : array();
             $customer_group = isset($customer['group_ids']) && is_array($customer['group_ids']) ? $customer['group_ids'] : array();
             $address = isset($_POST['address']) ? $_POST['address'] : array();
             $website = isset($_POST['website']) ? $_POST['website'] : array();
             $website_extra = isset($website['extra']) ? $website['extra'] : array();
             $website_group = isset($website['group_ids']) && is_array($website['group_ids']) ? $website['group_ids'] : array();
             $job = isset($_POST['job']) ? $_POST['job'] : array();
             $job_extra = isset($job['extra']) ? $job['extra'] : array();
             $subscription = isset($_POST['subscription']) ? $_POST['subscription'] : array();
             // sanatise possibly problematic fields:
             // customer:
             $allowed = array('name', 'last_name', 'customer_name', 'email', 'phone', 'mobile', 'extra', 'type');
             foreach ($customer as $key => $val) {
                 if (!in_array($key, $allowed)) {
                     unset($customer[$key]);
                 }
             }
             if (isset($customer['type']) && $customer['type'] != _CUSTOMER_TYPE_NORMAL && $customer['type'] != _CUSTOMER_TYPE_LEAD) {
                 unset($customer['type']);
             }
             // added multiple contact support in the form of arrays.
             $contact_fields = array('name', 'last_name', 'email', 'phone');
             if (module_config::c('customer_signup_password', 0)) {
                 $contact_fields[] = 'password';
             }
             foreach ($contact_fields as $multi_value) {
                 if (isset($contact[$multi_value])) {
                     if (!is_array($contact[$multi_value])) {
                         $contact[$multi_value] = array($contact[$multi_value]);
                     }
                 } else {
                     if (isset($customer[$multi_value])) {
                         $contact[$multi_value] = array($customer[$multi_value]);
                     } else {
                         $contact[$multi_value] = array();
                     }
                 }
             }
             $valid_contact_email = false;
             $name_fallback = false;
             $primary_email = false;
             foreach ($contact['email'] as $contact_key => $email) {
                 if (!$name_fallback && isset($contact['name'][$contact_key])) {
                     $name_fallback = $contact['name'][$contact_key];
                 }
                 $contact['email'][$contact_key] = filter_var(strtolower(trim($email)), FILTER_VALIDATE_EMAIL);
                 if ($contact['email'][$contact_key]) {
                     $valid_contact_email = true;
                     if (!$primary_email) {
                         $primary_email = $contact['email'][$contact_key];
                         // set the primary contact details here by adding them to the master customer array
                         foreach ($contact_fields as $primary_contact_field) {
                             $customer[$primary_contact_field] = isset($contact[$primary_contact_field][$contact_key]) ? $contact[$primary_contact_field][$contact_key] : '';
                             unset($contact[$primary_contact_field][$contact_key]);
                         }
                     }
                 }
             }
             // start error checking / required fields
             if (!isset($customer['customer_name']) || !strlen($customer['customer_name'])) {
                 $customer['customer_name'] = $name_fallback;
             }
             if (!strlen($customer['customer_name'])) {
                 $result['error'] = 1;
                 $result['messages'][] = "Failed, please go back and provide a customer name.";
             }
             if (!$valid_contact_email || !$primary_email) {
                 $result['error'] = 1;
                 $result['messages'][] = "Failed, please go back and provide an email address.";
             }
             // check all posted required fields.
             function check_required($postdata, $messages = array())
             {
                 if (is_array($postdata)) {
                     foreach ($postdata as $key => $val) {
                         if (strpos($key, '_required') && strlen($val)) {
                             $required_key = str_replace('_required', '', $key);
                             if (!isset($postdata[$required_key]) || !$postdata[$required_key]) {
                                 $messages[] = 'Required field missing: ' . htmlspecialchars($val);
                             }
                         }
                         if (is_array($val)) {
                             $messages = check_required($val, $messages);
                         }
                     }
                 }
                 return $messages;
             }
             $messages = check_required($_POST);
             if (count($messages)) {
                 $result['error'] = 1;
                 $result['messages'] = array_merge($result['messages'], $messages);
             }
             if (isset($result['error'])) {
                 customer_signup_complete($result);
             }
             // end error checking / required fields.
             // check if this customer already exists in the system, based on email address
             $customer_id = false;
             $creating_new = true;
             $_REQUEST['user_id'] = 0;
             if (isset($customer['email']) && strlen($customer['email']) && !module_config::c('customer_signup_always_new', 0)) {
                 $users = module_user::get_contacts(array('email' => $customer['email']));
                 foreach ($users as $user) {
                     if (isset($user['customer_id']) && (int) $user['customer_id'] > 0) {
                         // this user exists as a customer! yey!
                         // add them to this listing.
                         $customer_id = $user['customer_id'];
                         $creating_new = false;
                         $_REQUEST['user_id'] = $user['user_id'];
                         // dont let signups update existing passwords.
                         if (isset($customer['password'])) {
                             unset($customer['password']);
                         }
                         if (isset($customer['new_password'])) {
                             unset($customer['new_password']);
                         }
                     }
                 }
             }
             $_REQUEST['extra_customer_field'] = array();
             $_REQUEST['extra_user_field'] = array();
             module_extra::$config['allow_new_keys'] = false;
             module_extra::$config['delete_existing_empties'] = false;
             // save customer extra fields.
             if (count($customer_extra)) {
                 // format the address so "save_customer" handles the save for us
                 foreach ($customer_extra as $key => $val) {
                     $_REQUEST['extra_customer_field'][] = array('key' => $key, 'val' => $val);
                 }
             }
             // save customer and customer contact details:
             $customer_id = $this->save_customer($customer_id, $customer);
             if (!$customer_id) {
                 $result['error'] = 1;
                 $result['messages'][] = 'System error: failed to create customer.';
                 customer_signup_complete($result);
             }
             $customer_data = module_customer::get_customer($customer_id);
             // todo - merge primary and secondary contact/extra/group saving into a single loop
             if (!$customer_data['primary_user_id']) {
                 $result['error'] = 1;
                 $result['messages'][] = 'System error: Failed to create customer contact.';
                 customer_signup_complete($result);
             } else {
                 $role_id = module_config::c('customer_signup_role', 0);
                 if ($role_id > 0) {
                     module_user::add_user_to_role($customer_data['primary_user_id'], $role_id);
                 }
                 // save contact extra data (repeated below for additional contacts)
                 if (isset($contact_extra[0]) && count($contact_extra[0])) {
                     $_REQUEST['extra_user_field'] = array();
                     foreach ($contact_extra[0] as $key => $val) {
                         $_REQUEST['extra_user_field'][] = array('key' => $key, 'val' => $val);
                     }
                     module_extra::save_extras('user', 'user_id', $customer_data['primary_user_id']);
                 }
                 // save contact groups
                 if (isset($contact_group[0]) && count($contact_group[0])) {
                     foreach ($contact_group[0] as $group_id => $tf) {
                         if ($tf) {
                             module_group::add_to_group($group_id, $customer_data['primary_user_id'], 'user');
                         }
                     }
                 }
             }
             foreach ($contact['email'] as $contact_key => $email) {
                 // add any additional contacts to the customer.
                 $users = module_user::get_contacts(array('email' => $email, 'customer_id' => $customer_id));
                 if (count($users)) {
                     // this contact already exists for this customer, dont update/change it.
                     continue;
                 }
                 $new_contact = array('customer_id' => $customer_id);
                 foreach ($contact_fields as $primary_contact_field) {
                     $new_contact[$primary_contact_field] = isset($contact[$primary_contact_field][$contact_key]) ? $contact[$primary_contact_field][$contact_key] : '';
                 }
                 // dont let additional contacts have passwords.
                 if (isset($new_contact['password'])) {
                     unset($new_contact['password']);
                 }
                 if (isset($new_contact['new_password'])) {
                     unset($new_contact['new_password']);
                 }
                 global $plugins;
                 $contact_user_id = $plugins['user']->create_user($new_contact, 'signup');
                 if ($contact_user_id) {
                     $role_id = module_config::c('customer_signup_role', 0);
                     if ($role_id > 0) {
                         module_user::add_user_to_role($contact_user_id, $role_id);
                     }
                     // save contact extra data  (repeated below for primary contacts)
                     if (isset($contact_extra[$contact_key]) && count($contact_extra[$contact_key])) {
                         $_REQUEST['extra_user_field'] = array();
                         foreach ($contact_extra[$contact_key] as $key => $val) {
                             $_REQUEST['extra_user_field'][] = array('key' => $key, 'val' => $val);
                         }
                         module_extra::save_extras('user', 'user_id', $contact_user_id);
                     }
                     // save contact groups
                     if (isset($contact_group[$contact_key]) && count($contact_group[$contact_key])) {
                         foreach ($contact_group[$contact_key] as $group_id => $tf) {
                             if ($tf) {
                                 module_group::add_to_group($group_id, $contact_user_id, 'user');
                             }
                         }
                     }
                 }
             }
             if (count($customer_group)) {
                 // format the address so "save_customer" handles the save for us
                 foreach ($customer_group as $group_id => $tf) {
                     if ($tf) {
                         module_group::add_to_group($group_id, $customer_id, 'customer');
                     }
                 }
             }
             $note_keys = array('customer', 'website', 'job', 'address', 'subscription');
             $note_text = _l('Customer signed up from Signup Form:');
             $note_text .= "\n\n";
             foreach ($note_keys as $note_key) {
                 $note_text .= "\n" . ucwords(_l($note_key)) . "\n";
                 if (isset($_POST[$note_key]) && is_array($_POST[$note_key])) {
                     foreach ($_POST[$note_key] as $post_key => $post_val) {
                         $note_text .= "\n - " . _l($post_key) . ": ";
                         if (is_array($post_val)) {
                             foreach ($post_val as $p => $v) {
                                 $note_text .= "\n  - - " . _l($p) . ': ' . $v;
                             }
                         } else {
                             $note_text .= $post_val;
                         }
                     }
                 }
             }
             $note_data = array('note_id' => false, 'owner_id' => $customer_id, 'owner_table' => 'customer', 'note_time' => time(), 'note' => $note_text, 'rel_data' => module_customer::link_open($customer_id), 'reminder' => 0, 'user_id' => 0);
             update_insert('note_id', false, 'note', $note_data);
             // save customer address fields.
             if (count($address)) {
                 $address_db = module_address::get_address($customer_id, 'customer', 'physical');
                 $address_id = $address_db && isset($address_db['address_id']) ? (int) $address_db['address_id'] : false;
                 $address['owner_id'] = $customer_id;
                 $address['owner_table'] = 'customer';
                 $address['address_type'] = 'physical';
                 // we have post data to save, write it to the table!!
                 module_address::save_address($address_id, $address);
             }
             // website:
             $allowed = array('url', 'name', 'extra', 'notes');
             foreach ($website as $key => $val) {
                 if (!in_array($key, $allowed)) {
                     unset($website[$key]);
                 }
             }
             $website['url'] = isset($website['url']) ? strtolower(trim($website['url'])) : '';
             $website_id = 0;
             if (count($website) && class_exists('module_website', false) && module_website::is_plugin_enabled()) {
                 if (strlen($website['url'])) {
                     // see if website already exists, don't create or update existing one for now.
                     $existing_websites = module_website::get_websites(array('customer_id' => $customer_id, 'url' => $website['url']));
                     foreach ($existing_websites as $existing_website) {
                         $website_id = $existing_website['website_id'];
                     }
                 }
                 //   echo $website_id;echo $website['url']; print_r($website_extra);exit;
                 if (!$website_id) {
                     $website_data = module_website::get_website($website_id);
                     $website_data['url'] = isset($website['url']) ? $website['url'] : 'N/A';
                     $website_data['name'] = isset($website['url']) ? $website['url'] : 'N/A';
                     $website_data['customer_id'] = $customer_id;
                     $website_id = update_insert('website_id', false, 'website', $website_data);
                     // save website extra data.
                     if ($website_id && count($website_extra)) {
                         $_REQUEST['extra_website_field'] = array();
                         foreach ($website_extra as $key => $val) {
                             $_REQUEST['extra_website_field'][] = array('key' => $key, 'val' => $val);
                         }
                         module_extra::save_extras('website', 'website_id', $website_id);
                     }
                     if ($website_id && isset($website['notes']) && strlen($website['notes'])) {
                         // add notes to this website.
                         $note_data = array('note_id' => false, 'owner_id' => $website_id, 'owner_table' => 'website', 'note_time' => time(), 'note' => $website['notes'], 'rel_data' => module_website::link_open($website_id), 'reminder' => 0, 'user_id' => $customer_data['primary_user_id']);
                         $note_id = update_insert('note_id', false, 'note', $note_data);
                     }
                 }
                 if ($website_id) {
                     if (count($website_group)) {
                         // format the address so "save_customer" handles the save for us
                         foreach ($website_group as $group_id => $tf) {
                             if ($tf) {
                                 module_group::add_to_group($group_id, $website_id, 'website');
                             }
                         }
                     }
                 }
             }
             // generate jobs for this customer.
             $job_created = array();
             if ($job && isset($job['type']) && is_array($job['type'])) {
                 if (module_config::c('customer_signup_any_job_type', 0)) {
                     foreach ($job['type'] as $type_name) {
                         // we have a match in our system. create the job.
                         $job_data = module_job::get_job(false);
                         $job_data['type'] = $type_name;
                         if (!$job_data['name']) {
                             $job_data['name'] = $type_name;
                         }
                         $job_data['website_id'] = $website_id;
                         $job_data['customer_id'] = $customer_id;
                         $job_id = update_insert('job_id', false, 'job', $job_data);
                         // todo: add default tasks for this job type.
                         $job_created[] = $job_id;
                     }
                 } else {
                     foreach (module_job::get_types() as $type_id => $type) {
                         foreach ($job['type'] as $type_name) {
                             if ($type_name == $type) {
                                 // we have a match in our system. create the job.
                                 $job_data = module_job::get_job(false);
                                 $job_data['type'] = $type;
                                 if (!$job_data['name']) {
                                     $job_data['name'] = $type;
                                 }
                                 $job_data['website_id'] = $website_id;
                                 $job_data['customer_id'] = $customer_id;
                                 $job_id = update_insert('job_id', false, 'job', $job_data);
                                 // todo: add default tasks for this job type.
                                 $job_created[] = $job_id;
                             }
                         }
                     }
                 }
                 if (count($job_created) && count($job_extra)) {
                     // save job extra data.
                     foreach ($job_created as $job_created_id) {
                         if ($job_created_id && count($job_extra)) {
                             $_REQUEST['extra_job_field'] = array();
                             foreach ($job_extra as $key => $val) {
                                 $_REQUEST['extra_job_field'][] = array('key' => $key, 'val' => $val);
                             }
                             module_extra::save_extras('job', 'job_id', $job_created_id);
                         }
                     }
                 }
             }
             // save files against customer
             $uploaded_files = array();
             if (isset($_FILES['customerfiles']) && isset($_FILES['customerfiles']['tmp_name'])) {
                 foreach ($_FILES['customerfiles']['tmp_name'] as $file_id => $tmp_file) {
                     if (is_uploaded_file($tmp_file)) {
                         // save to file module for this customer
                         $file_name = basename($_FILES['customerfiles']['name'][$file_id]);
                         if (strlen($file_name)) {
                             $file_path = 'includes/plugin_file/upload/' . md5(time() . $file_name);
                             if (move_uploaded_file($tmp_file, $file_path)) {
                                 // success! write to db.
                                 $file_data = array('customer_id' => $customer_id, 'job_id' => current($job_created), 'website_id' => $website_id, 'status' => module_config::c('file_default_status', 'Uploaded'), 'pointers' => false, 'description' => "Uploaded from Customer Signup form", 'file_time' => time(), 'file_name' => $file_name, 'file_path' => $file_path, 'file_url' => false);
                                 $file_id = update_insert('file_id', false, 'file', $file_data);
                                 $uploaded_files[] = $file_id;
                             }
                         }
                     }
                 }
             }
             // we create subscriptions for this customer/website (if none already exist)
             $subscription['subscription_name'] = array();
             $subscription['subscription_invoice'] = array();
             if (class_exists('module_subscription', false) && module_subscription::is_plugin_enabled() && isset($subscription['for']) && isset($subscription['subscriptions'])) {
                 if ($subscription['for'] == 'website' && $website_id > 0) {
                     $owner_table = 'website';
                     $owner_id = $website_id;
                 } else {
                     $owner_table = 'customer';
                     $owner_id = $customer_id;
                 }
                 $available_subscriptions = module_subscription::get_subscriptions();
                 $members_subscriptions = module_subscription::get_subscriptions_by($owner_table, $owner_id);
                 foreach ($subscription['subscriptions'] as $subscription_id => $tf) {
                     if (isset($available_subscriptions[$subscription_id])) {
                         if (isset($members_subscriptions[$subscription_id])) {
                             // we don't allow a member to sign up to the same subscription twice (just yet)
                         } else {
                             $subscription['subscription_name'][$subscription_id] = $available_subscriptions[$subscription_id]['name'];
                             $start_date = date('Y-m-d');
                             $start_modifications = module_config::c('customer_signup_subscription_start', '');
                             if ($start_modifications == 'hidden') {
                                 $start_modifications = isset($_REQUEST['customer_signup_subscription_start']) ? $_REQUEST['customer_signup_subscription_start'] : '';
                             }
                             if (!empty($start_modifications)) {
                                 $start_date = date('Y-m-d', strtotime($start_modifications));
                             }
                             $sql = "INSERT INTO `" . _DB_PREFIX . "subscription_owner` SET ";
                             $sql .= " owner_id = '" . (int) $owner_id . "'";
                             $sql .= ", owner_table = '" . mysql_real_escape_string($owner_table) . "'";
                             $sql .= ", subscription_id = '" . (int) $subscription_id . "'";
                             $sql .= ", start_date = '{$start_date}'";
                             query($sql);
                             module_subscription::update_next_due_date($subscription_id, $owner_table, $owner_id, true);
                             // and the same option here to send a subscription straight away upon signup
                             if (module_config::c('subscription_send_invoice_straight_away', 0)) {
                                 global $plugins;
                                 $plugins['subscription']->run_cron();
                                 // check if there are any invoices for this subscription
                                 $history = module_subscription::get_subscription_history($subscription_id, $owner_table, $owner_id);
                                 if (count($history) > 0) {
                                     foreach ($history as $h) {
                                         if ($h['invoice_id']) {
                                             $invoice_data = module_invoice::get_invoice($h['invoice_id']);
                                             if ($invoice_data['date_cancel'] != '0000-00-00') {
                                                 continue;
                                             }
                                             $subscription['subscription_invoice'][] = '<a href="' . module_invoice::link_public($h['invoice_id']) . '">' . _l('Invoice #%s for %s', htmlspecialchars($invoice_data['name']), dollar($invoice_data['total_amount'], true, $invoice_data['currency_id'])) . '</a>';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (!count($subscription['subscription_name'])) {
                 $subscription['subscription_name'][] = _l('N/A');
             }
             if (!count($subscription['subscription_invoice'])) {
                 $subscription['subscription_invoice'][] = _l('N/A');
             }
             $subscription['subscription_name'] = implode(', ', $subscription['subscription_name']);
             $subscription['subscription_invoice'] = implode(', ', $subscription['subscription_invoice']);
             // email the admin when a customer signs up.
             $values = array_merge($customer, $customer_extra, $website, $website_extra, $address, $subscription);
             $values['customer_name'] = $customer['customer_name'];
             $values['CUSTOMER_LINK'] = module_customer::link_open($customer_id);
             $values['CUSTOMER_NAME_LINK'] = module_customer::link_open($customer_id, true);
             if ($website_id) {
                 $values['WEBSITE_LINK'] = module_website::link_open($website_id);
                 $values['WEBSITE_NAME_LINK'] = module_website::link_open($website_id, true);
             } else {
                 $values['WEBSITE_LINK'] = _l('N/A');
                 $values['WEBSITE_NAME_LINK'] = _l('N/A');
             }
             $values['JOB_LINKS'] = '';
             if (count($job_created)) {
                 $values['JOB_LINKS'] .= 'The customer created ' . count($job_created) . ' jobs in the system: <br>';
                 foreach ($job_created as $job_created_id) {
                     $values['JOB_LINKS'] .= module_job::link_open($job_created_id, true) . "<br>\n";
                 }
             } else {
                 $values['JOB_LINKS'] = _l('N/A');
             }
             if (count($uploaded_files)) {
                 $values['uploaded_files'] = 'The customer uploaded ' . count($uploaded_files) . " files:<br>\n";
                 foreach ($uploaded_files as $uploaded_file) {
                     $values['uploaded_files'] .= module_file::link_open($uploaded_file, true) . "<br>\n";
                 }
             } else {
                 $values['uploaded_files'] = 'No files were uploaded';
             }
             $values['WEBSITE_NAME'] = isset($website['url']) ? $website['url'] : 'N/A';
             if (!$creating_new) {
                 $values['system_note'] = "Note: this signup updated the existing customer record in the system.";
             } else {
                 $values['system_note'] = "Note: this signup created a new customer record in the system.";
             }
             $customer_signup_template = module_config::c('customer_signup_email_admin_template', 'customer_signup_email_admin');
             if (isset($_REQUEST['customer_signup_email_admin_template'])) {
                 $customer_signup_template = $_REQUEST['customer_signup_email_admin_template'];
             }
             if ($customer_signup_template) {
                 $template = module_template::get_template_by_key($customer_signup_template);
                 if ($template->template_id) {
                     $template->assign_values($values);
                     $html = $template->render('html');
                     $email = module_email::new_email();
                     $email->replace_values = $values;
                     $email->set_subject($template->description);
                     $email->set_to_manual(module_config::c('customer_signup_admin_email', module_config::c('admin_email_address')));
                     // do we send images inline?
                     $email->set_html($html);
                     if ($email->send()) {
                         // it worked successfully!!
                     } else {
                         /// log err?
                     }
                 }
             }
             $customer_signup_template = module_config::c('customer_signup_email_welcome_template', 'customer_signup_email_welcome');
             if (isset($_REQUEST['customer_signup_email_welcome_template'])) {
                 $customer_signup_template = $_REQUEST['customer_signup_email_welcome_template'];
             }
             if ($customer_signup_template) {
                 $template = module_template::get_template_by_key($customer_signup_template);
                 if ($template->template_id) {
                     $template->assign_values($values);
                     $html = $template->render('html');
                     $email = module_email::new_email();
                     $email->customer_id = $customer_id;
                     $email->replace_values = $values;
                     $email->set_subject($template->description);
                     $email->set_to('user', $customer_data['primary_user_id']);
                     // do we send images inline?
                     $email->set_html($html);
                     if ($email->send()) {
                         // it worked successfully!!
                     } else {
                         /// log err?
                     }
                 }
             }
             //todo: optional redirect to url
             if (isset($_REQUEST['via_ajax'])) {
                 echo json_encode(array('success' => 1, 'customer_id' => $customer_id));
                 exit;
             }
             if (module_config::c('customer_signup_redirect', '')) {
                 redirect_browser(module_config::c('customer_signup_redirect', ''));
             }
             // load up the thank you template.
             $template = module_template::get_template_by_key('customer_signup_thank_you_page');
             $template->page_title = _l("Customer Signup");
             foreach ($values as $key => $val) {
                 if (!is_array($val)) {
                     $values[$key] = htmlspecialchars($val);
                 }
             }
             $template->assign_values($values);
             echo $template->render('pretty_html');
             exit;
             break;
     }
 }
Example #9
0
// find available "to" recipients.
// customer contacts.
$to_select = false;
if ($file['customer_id']) {
    $customer = module_customer::get_customer($file['customer_id']);
    $file['customer_name'] = $customer['customer_name'];
    $to = module_user::get_contacts(array('customer_id' => $file['customer_id']));
    if ($customer['primary_user_id']) {
        $primary = module_user::get_user($customer['primary_user_id']);
        if ($primary) {
            $to_select = $primary['email'];
        }
    }
} else {
    $to = array();
}
if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
    $all_extra_fields = module_extra::get_defaults('file');
    foreach ($all_extra_fields as $e) {
        $file[$e['key']] = _l('N/A');
    }
    // and find the ones with values:
    $extras = module_extra::get_extras(array('owner_table' => 'file', 'owner_id' => $file_id));
    foreach ($extras as $e) {
        $file[$e['extra_key']] = $e['extra'];
    }
}
$template->assign_values($file);
ob_start();
module_email::print_compose(array('title' => _l('Email File: %s', $file['file_name']), 'find_other_templates' => 'file_approval_email', 'current_template' => $template_name, 'customer_id' => $file['customer_id'], 'job_id' => $file['job_id'], 'file_id' => $file['file_id'], 'debug_message' => 'Sending file as email', 'to' => $to, 'to_select' => $to_select, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_file::link_open($file_id), 'success_callback' => 'module_file::email_sent', 'success_callback_args' => array('file_id' => $file_id), 'cancel_url' => module_file::link_open($file_id)));
            if (isset($data[$key]) && (int) $data[$key] > 0) {
                switch ($key) {
                    case 'customer_id':
                        echo module_customer::link_open($data[$key], true);
                        break;
                    case 'job_id':
                        echo module_job::link_open($data[$key], true);
                        break;
                    case 'invoice_id':
                        echo module_invoice::link_open($data[$key], true);
                        break;
                    case 'quote_id':
                        echo module_quote::link_open($data[$key], true);
                        break;
                    case 'file_id':
                        echo module_file::link_open($data[$key], true);
                        break;
                }
            }
        }
        ?>
</td>
            <?php 
    }
    /*<td><a href="<?php echo $module->link('',array("data_record_id"=>$data['data_record_id'],"customer_id"=>isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false)); ?>"><?php echo $module->format_record_id($data['data_type_id'],$data['data_record_id']); ?></a></td>
      <td><?php echo $data['status']; ?></td>
      <td><?php echo print_date($data['date_updated']); ?></td>
      <?php */
    $first = true;
    foreach ($list_fields as $list_field) {
        $settings = @unserialize($list_data_items[$list_field['data_field_id']]['data_field_settings']);
Example #11
0
    }
    //print_heading($heading);
    $company_fields = array();
    $companys = module_company::get_companys();
    foreach ($companys as $company) {
        $company_fields[] = array('type' => 'hidden', 'name' => "available_vendor_company[" . $company['company_id'] . "]", 'value' => 1);
        $company_fields[] = array('type' => 'check', 'name' => "vendor_company[" . $company['company_id'] . "]", 'value' => $company['company_id'], 'checked' => isset($vendor['company_ids'][$company['company_id']]) || !$vendor_id && !module_company::can_i('edit', 'Company'), 'label' => htmlspecialchars($company['name']));
    }
    $fieldset_data = array('heading' => $heading, 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('company' => array('title' => _l('Company'), 'fields' => $company_fields)));
    echo module_form::generate_fieldset($fieldset_data);
}
/** VENDOR INFORMATION **/
$fieldset_data = array('heading' => array('type' => 'h3', 'title' => $page_type_single . ' Information'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('name' => array('title' => _l('Name'), 'field' => array('type' => 'text', 'name' => 'vendor_name', 'value' => $vendor['vendor_name']))), 'extra_settings' => array('owner_table' => 'vendor', 'owner_key' => 'vendor_id', 'owner_id' => $vendor_id, 'layout' => 'table_row', 'allow_new' => module_vendor::can_i('create', $page_type), 'allow_edit' => module_vendor::can_i('create', $page_type)));
if ($vendor_id && $vendor_id != 'new' && class_exists('module_file') && module_file::is_plugin_enabled()) {
    ob_start();
    module_file::display_files(array('owner_table' => 'vendor', 'owner_id' => $vendor_id, 'layout' => 'gallery', 'editable' => module_security::is_page_editable()));
    $fieldset_data['elements']['logo'] = array('title' => _l('Logo'), 'field' => ob_get_clean());
}
echo module_form::generate_fieldset($fieldset_data);
/** PRIMARY CONTACT DETAILS **/
// we use the "user" module to find the user details
// for the currently selected primary contact id
if ($vendor['primary_user_id']) {
    if (!module_user::can_i('view', 'All ' . $page_type_single . ' Contacts', 'Vendor', 'vendor') && $vendor['primary_user_id'] != module_security::get_loggedin_id()) {
        ob_start();
        echo '<div class="content_box_wheader"><table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form"><tbody><tr><td>';
        _e('Details hidden');
        echo '</td></tr></tbody></table></div>';
        $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Primary Contact Details'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements_before' => ob_get_clean());
        if ($vendor['primary_user_id']) {
            $fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($vendor['primary_user_id'], false));
Example #12
0
			<tr>
				<td align="center" colspan="2">
					<input type="submit" name="butt_save" id="butt_save" value="<?php 
echo _l('Save file');
?>
" class="submit_button save_button" />
					<?php 
if ((int) $file_id) {
    ?>
					<input type="submit" name="butt_del" id="butt_del" value="<?php 
    echo _l('Delete');
    ?>
" class="submit_button delete_button" />
					<?php 
}
?>
					<input type="button" name="cancel" value="<?php 
echo _l('Cancel');
?>
" onclick="window.location.href='<?php 
echo module_file::link_open(false);
?>
';" class="submit_button" />
				</td>
			</tr>
		</tbody>
	</table>


</form>
Example #13
0
 $table_manager = module_theme::new_table_manager();
 $columns = array();
 $columns['backup_name'] = array('title' => 'Backup', 'callback' => function ($backup) {
     echo '<a href="' . module_backup::link_open($backup['backup_id'], false) . '">' . _l('View Backup') . '</a>';
 }, 'cell_class' => 'row_action');
 $columns['backup_size'] = array('title' => 'Backup Size', 'callback' => function ($backup) {
     if (strlen($backup['backup_file']) && file_exists(_BACKUP_BASE_DIR . basename($backup['backup_file']) . '.zip')) {
         echo module_file::format_bytes(filesize(_BACKUP_BASE_DIR . basename($backup['backup_file']) . '.zip')) . ' ' . _l('files');
         echo ' ';
     }
     if (strlen($backup['backup_file']) && file_exists(_BACKUP_BASE_DIR . basename($backup['backup_file']) . '.sql')) {
         echo module_file::format_bytes(filesize(_BACKUP_BASE_DIR . basename($backup['backup_file']) . '.sql')) . ' ' . _l('database');
         echo ' ';
     }
     if (strlen($backup['backup_file']) && file_exists(_BACKUP_BASE_DIR . basename($backup['backup_file']) . '.sql.gz')) {
         echo module_file::format_bytes(filesize(_BACKUP_BASE_DIR . basename($backup['backup_file']) . '.sql.gz')) . ' ' . _l('database');
         echo ' ';
     }
 });
 $columns['backup_date'] = array('title' => 'Date Created', 'callback' => function ($backup) {
     echo _l('%s by %s', print_date($backup['date_created']), module_user::link_open($backup['create_user_id'], true));
 });
 $table_manager->set_columns($columns);
 $table_manager->set_rows($backups);
 if (module_config::c('backup_time', 0) > 0) {
     $table_manager->blank_message = _l('The last backup was: %s', print_date(module_config::c('backup_time', 0), true));
 } else {
     $table_manager->blank_message = _l('No backups yet. Please create one.');
 }
 $table_manager->pagination = false;
 $table_manager->print_table();
Example #14
0
		    <a href="<?php 
        echo module_file::link_generate(false, array('arguments' => array('quote_id' => $quote['quote_id']), 'data' => array('quote_id' => $quote['quote_id'])));
        ?>
"><?php 
        echo _l('View all %d files in this quote', count($files));
        ?>
</a>
	    <?php 
    } else {
        echo _l("This quote has %d files", count($files));
    }
    echo '<br/>';
    ?>

	    <a href="<?php 
    echo module_file::link_generate('new', array('arguments' => array('quote_id' => $quote['quote_id'])));
    ?>
"><?php 
    _e('Add New File');
    ?>
</a>
	    <?php 
    $fieldset_data['elements']['files'] = array('title' => 'Files', 'fields' => array(ob_get_clean()));
}
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
if (module_config::c('quote_enable_description', 1)) {
    if (!module_quote::can_i('edit', 'Quotes') && !$quote['description']) {
        // no description, no ability to edit description, don't show anything.
    } else {
        // can edit description
Example #15
0
 /**
  *
  * This is called from newsletter_queue_manual.php and the cron job (todo)
  * This will pick the next email in the queue to send and send it.
  * If there are any problems it will record the problem and return the error to the calling function for display.
  * TODO: make this support more than one at a time in send_limit (put newsletter_member_id into an array and return that)
  *
  * @static
  * @param $newsletter_id
  * @param $send_id
  * @param int $send_limit
  * @param bool $retry_failures
  * @return array
  */
 public static function process_send($newsletter_id, $send_id, $send_limit = 1, $retry_failures = false, $retry_pending = false)
 {
     $newsletter_id = (int) $newsletter_id;
     $send_id = (int) $send_id;
     // todo, make the result friendly for multiple members.
     $result = array('send_count' => 0, 'send_members' => array());
     $send_count = 0;
     // we pick the next member off the list in this send and send it out.
     // check the status of this send is still ok to send.
     $sql = "SELECT `send_id`,`status` FROM `" . _DB_PREFIX . "newsletter_send` WHERE `newsletter_id` = {$newsletter_id} AND `send_id` = {$send_id}";
     // $sql .= " AND `status` = " . _NEWSLETTER_STATUS_PENDING ;
     $status_check = qa1($sql, false);
     if ($status_check['send_id'] == $send_id) {
         //$status_check['status']==_NEWSLETTER_STATUS_PENDING &&
         // we have a go for sending to the next member!
         $sql = "SELECT sm.*, m.* FROM `" . _DB_PREFIX . "newsletter_send_member` sm ";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "newsletter_member` m ON sm.newsletter_member_id = m.newsletter_member_id ";
         // update! we assume all members in the newsletter_send_member table are legit and not unsubscribed.
         /// this is because we're now removing all unsubscribed members from the mailing list before sending starts.
         //$sql .= " LEFT JOIN `"._DB_PREFIX."newsletter_blacklist` b ON m.email = b.email ";
         $sql .= " WHERE sm.`send_id` = {$send_id} ";
         //sql .= " AND b.newsletter_blacklist_id IS NULL ";
         // copied from get send members:
         //$sql .= " AND m.bounce_count < ".(int)module_config::c('newsletter_bounce_threshold',3);
         //$sql .= " AND m.receive_email = 1";
         //$sql .= " AND m.email != ''";
         //$sql .= " AND (m.unsubscribe_date IS NULL OR m.unsubscribe_date = '0000-00-00')";
         //$sql .= " AND b.email IS NULL";
         // todo - instead of this sql query pass this back to our central "get send members" query
         if ($retry_failures) {
             $sql .= " AND sm.`status` = " . _NEWSLETTER_STATUS_FAILED . " AND sm.newsletter_member_id > 0";
         } else {
             if ($retry_pending) {
                 $sql .= " AND sm.`status` = " . _NEWSLETTER_STATUS_PENDING . " AND sm.newsletter_member_id > 0";
             } else {
                 $sql .= " AND (sm.`status` = " . _NEWSLETTER_STATUS_NEW . " OR sm.`status` = " . _NEWSLETTER_STATUS_PAUSED . ") AND sm.newsletter_member_id > 0";
             }
         }
         $sql .= " GROUP BY sm.newsletter_member_id ";
         $send_member_list = query($sql);
         if (mysql_num_rows($send_member_list) > 0) {
             while ($send_member = mysql_fetch_assoc($send_member_list)) {
                 if ($send_count >= $send_limit) {
                     break;
                 }
                 // have we already tried sending this member in this loop?
                 if (($retry_failures || $retry_pending) && isset(self::$failed_retries[$send_member['newsletter_member_id']])) {
                     continue;
                 }
                 self::$failed_retries[$send_member['newsletter_member_id']] = true;
                 // a quick lock checking on the member to ensure we don't send it twice
                 // first we check the status of the member.
                 if ($retry_failures || $retry_pending) {
                 } else {
                     // added this in just to be sure we're not sending out duplicates...
                     $sql = "SELECT * FROM `" . _DB_PREFIX . "newsletter_send_member` WHERE (`status` = " . _NEWSLETTER_STATUS_NEW . " OR `status` = " . _NEWSLETTER_STATUS_PAUSED . ") AND `send_id` = {$send_id} AND newsletter_member_id = '" . (int) $send_member['newsletter_member_id'] . "'";
                     $duplicate_check = qa1($sql);
                     if (empty($duplicate_check)) {
                         // cant find this member, already sent this one then!
                         continue;
                     }
                 }
                 // and we do another check just to make sure we're not sending out duplicates again:
                 $sql = "UPDATE `" . _DB_PREFIX . "newsletter_send_member` SET `status` = " . _NEWSLETTER_STATUS_PENDING . " WHERE `send_id` = {$send_id} AND newsletter_member_id = '" . (int) $send_member['newsletter_member_id'] . "' AND `status` != " . _NEWSLETTER_STATUS_PENDING . "";
                 query($sql);
                 if ($retry_pending || mysql_affected_rows()) {
                     // we haev a lock on this member! ok to proceed.
                     $member_result['newsletter_member_id'] = (int) $send_member['newsletter_member_id'];
                     // check this member hasn't unsubscribed or any other issues with it...
                     $newsletter = self::get_newsletter($newsletter_id);
                     // both these two do their own "replacey" things. same inside email.
                     $fields = self::get_replace_fields($newsletter_id, $send_id, $send_member['newsletter_member_id'], true);
                     $html = self::render($newsletter_id, $send_id, $send_member['newsletter_member_id'], 'real');
                     // make any changes here in the send_preview method as well.
                     $email = module_email::new_email();
                     $email->replace_values = $fields;
                     $email->set_bounce_address($newsletter['bounce_email']);
                     $email->set_from_manual($newsletter['from_email'], $newsletter['from_name']);
                     $email->set_to_manual($send_member['email'], $newsletter['to_name']);
                     $email->set_subject($newsletter['subject']);
                     // do we send images inline?
                     $email->set_html($html);
                     $email->message_id = self::generate_bounce_message_id($newsletter_id, $send_id, $send_member['newsletter_member_id']);
                     // do we attach anything else?
                     $files = module_file::get_files(array('owner_table' => 'newsletter_files', 'owner_id' => $newsletter_id));
                     foreach ($files as $file_data) {
                         if (is_file($file_data['file_path'])) {
                             $email->AddAttachment($file_data['file_path'], $file_data['file_name']);
                         }
                     }
                     if ($email->send()) {
                         // it worked successfully!!
                     }
                     $member_result['error'] = $email->error_text;
                     $member_result['email'] = $send_member['email'];
                     switch ($email->status) {
                         case _MAIL_STATUS_OVER_QUOTA:
                             // over quota! pause this send until another time.
                             $sql = "UPDATE `" . _DB_PREFIX . "newsletter_send_member` SET `status` = " . _NEWSLETTER_STATUS_PAUSED . ", `sent_time` = 0, `bounce_time` = 0 WHERE `send_id` = {$send_id} AND newsletter_member_id = '" . (int) $send_member['newsletter_member_id'] . "'";
                             query($sql);
                             break;
                         case _MAIL_STATUS_FAILED:
                             //self::member_email_bounced($send_member['newsletter_member_id'],$send_id);
                             $sql = "UPDATE `" . _DB_PREFIX . "newsletter_send_member` SET `status` = " . _NEWSLETTER_STATUS_FAILED . ", `bounce_time` = '0' WHERE `send_id` = {$send_id} AND newsletter_member_id = '" . (int) $send_member['newsletter_member_id'] . "'";
                             query($sql);
                             break;
                         case _MAIL_STATUS_SENT:
                         default:
                             // update its status to sent.
                             // do this as a default catch so we don't end up sending duplicates for some weird mail class error.
                             $sql = "UPDATE `" . _DB_PREFIX . "newsletter_send_member` SET `status` = " . _NEWSLETTER_STATUS_SENT . ", `sent_time` = '" . time() . "', `bounce_time` = 0 WHERE `send_id` = {$send_id} AND newsletter_member_id = '" . (int) $send_member['newsletter_member_id'] . "'";
                             query($sql);
                             break;
                     }
                     $member_result['status'] = $email->status;
                     // so the calling script can handle whatever as well.
                     $result['send_members'][(int) $send_member['newsletter_member_id']] = $member_result;
                     $send_count++;
                 } else {
                     // didn't get a lock on that member for some reason.
                     // probably because the cron job is runing in the background on this same send.
                 }
             }
         } else {
             // no more members left?
             // update this send to completd.
             $sql = "UPDATE `" . _DB_PREFIX . "newsletter_send` SET `status` = " . _NEWSLETTER_STATUS_SENT . ", finish_time = '" . time() . "' WHERE `send_id` = {$send_id}";
             query($sql);
         }
     }
     $result['send_count'] = $send_count;
     return $result;
 }
Example #16
0
    $fieldset_data['elements'][] = array('title' => 'Linked Staff', 'fields' => array(function () use(&$finance, $locked, $linked_staff_members) {
        ?>
 <input type="hidden" name="job_staff_expense" value="<?php 
        echo isset($finance['job_staff_expense']) ? (int) $finance['job_staff_expense'] : '';
        ?>
">
                    <?php 
        echo print_select_box($linked_staff_members, 'user_id', isset($finance['user_id']) ? $finance['user_id'] : 0, '', _l(' - None - '));
        if (isset($finance['user_id']) && $finance['user_id']) {
            echo ' <a href="' . module_user::link_open($finance['user_id'], false) . '">' . _l('Open User') . '</a>';
        }
    }));
}
$fieldset_data['elements'][] = array('title' => 'Attachment', 'fields' => array(function () use(&$finance, $locked, $finance_id) {
    if ((int) $finance_id > 0) {
        module_file::display_files(array('owner_table' => 'finance', 'owner_id' => $finance_id, 'layout' => 'gallery', 'editable' => module_security::is_page_editable() && module_finance::can_i('edit', 'Finance')));
    } else {
        _e('Please press save first');
    }
}));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save_return', 'value' => _l('Save and Return')), array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save'))));
if ((int) $finance_recurring_id > 0 && isset($_SESSION['_finance_recurring_ids'])) {
    // find if there is a next recurring id
    $next = 0;
    foreach ($_SESSION['_finance_recurring_ids'] as $next_data) {
        if ($next == -1) {
            $next = 1;
            // done.
            $form_actions['elements'][] = array('type' => 'hidden', 'name' => 'recurring_next', 'id' => 'recurring_next', 'value' => '');