function front_end_order_page_addon($order)
 {
     /* var_dump($_POST); */
     $default_width = get_option('thumbnail' . '_size_w');
     $default_height = get_option('thumbnail' . '_size_h');
     $order_id = $order->id;
     $file_order_metadata = get_post_meta($order_id, '_wcam_attachments_meta');
     $file_order_metadata = !$file_order_metadata ? array() : $file_order_metadata[0];
     $options = new WCAM_Option();
     $preview_image = $options->get_option('dispaly_image_preview', 'no');
     $select_box_style = $options->get_option('approval_box_style', 'select');
     $preview_image_height = $options->get_option('thumb_height', $default_height);
     $preview_image_width = $options->get_option('thumb_width', $default_width);
     if (isset($_POST) && isset($_POST['wcam_save_customer_feedbacks'])) {
         $file_order_metadata = $this->saveCustomerFeedbacks($order_id, $file_order_metadata);
     }
     if (!empty($file_order_metadata)) {
         $all_options = $options->get_option();
         //Texts and Miltilanguages
         $wpml = new WCAM_Wpml();
         $curr_lang = $wpml->get_current_language();
         $title = isset($all_options['title_box']) && isset($all_options['title_box'][$curr_lang]) ? $all_options['title_box'][$curr_lang] : __('Attachments', 'woocommerce-attach-me');
         $download_view_button_text = isset($all_options['download_view_button_text']) && isset($all_options['download_view_button_text'][$curr_lang]) ? $all_options['download_view_button_text'][$curr_lang] : __('Download / View', 'woocommerce-attach-me');
         $approve_box_title = isset($all_options['approve_box_title']) && isset($all_options['approve_box_title'][$curr_lang]) ? $all_options['approve_box_title'][$curr_lang] : __('Do you approve?', 'woocommerce-attach-me');
         $approve_already_sent_message = isset($all_options['approve_already_sent_message']) && isset($all_options['approve_already_sent_message'][$curr_lang]) ? $all_options['approve_already_sent_message'][$curr_lang] : __('Approvation already sent. Selected value was:', 'woocommerce-attach-me');
         $approve_not_yet_text = isset($all_options['approve_not_yet_text']) && isset($all_options['approve_not_yet_text'][$curr_lang]) ? $all_options['approve_not_yet_text'][$curr_lang] : __('Not yet', 'woocommerce-attach-me');
         $approve_yes_text = isset($all_options['approve_yes_text']) && isset($all_options['approve_yes_text'][$curr_lang]) ? $all_options['approve_yes_text'][$curr_lang] : __('Yes', 'woocommerce-attach-me');
         $approve_no_text = isset($all_options['approve_no_text']) && isset($all_options['approve_no_text'][$curr_lang]) ? $all_options['approve_no_text'][$curr_lang] : __('No', 'woocommerce-attach-me');
         $feedback_box_title = isset($all_options['feedback_box_title']) && isset($all_options['feedback_box_title'][$curr_lang]) ? $all_options['feedback_box_title'][$curr_lang] : __('Please enter a feedback', 'woocommerce-attach-me');
         wp_enqueue_style('css-wcam_frontend', wcam_PLUGIN_PATH . '/css/wcma-frontend.css');
         if (file_exists(get_template_directory() . "/wcam/view_order_template.php")) {
             include get_template_directory() . "/wcam/view_order_template.php";
         } else {
             include 'templates/view_order_template.php';
         }
     }
 }
Example #2
0
 function upload_files($order_id, $file_order_metadata, $attachments, $attachments_titles)
 {
     foreach ($_FILES as $prefix_id => $file_data) {
         list($prefix, $id) = explode("-", $prefix_id);
         if ($file_data["name"] != '') {
             $this->current_order = $order_id;
             //upload
             $upload_overrides = array('test_form' => false, 'unique_filename_callback' => array($this, 'generate_unique_file_name'));
             add_filter('upload_dir', array(&$this, 'wcam_ovveride_upload_directory'));
             $movefile = wp_handle_upload($file_data, $upload_overrides);
             remove_filter('upload_dir', array(&$this, 'wcam_ovveride_upload_directory'));
             if ($movefile && !isset($movefile['error'])) {
                 //creation of fake indexes
                 //$secure_sub = "";
                 $upload_dir = wp_upload_dir();
                 $options = new WCAM_Option();
                 $folder_name = $options->get_option('folder_name', 'wcam');
                 if (!file_exists($upload_dir['basedir'] . '/' . $folder_name . '/index.html')) {
                     touch($upload_dir['basedir'] . '/' . $folder_name . '/index.html');
                 }
                 if (!file_exists($upload_dir['basedir'] . '/' . $folder_name . '/' . $order_id . '/index.html')) {
                     touch($upload_dir['basedir'] . '/' . $folder_name . '/' . $order_id . '/index.html');
                 }
                 $title = !empty($attachments_titles) && isset($attachments_titles[$id]) ? $attachments_titles[$id] : "";
                 //$file_order_metadata[$id]['unique_id'] =
                 //$file_order_metadata[$id]['user_id'] =
                 $file_order_metadata[$id]['absolute_path'] = $movefile['file'];
                 $file_order_metadata[$id]['url'] = $movefile['url'];
                 $file_order_metadata[$id]['title'] = $title;
                 $file_order_metadata[$id]['id'] = $id;
                 $file_order_metadata[$id]['customer-has-to-be-approved'] = isset($_POST['wcam-customer-approve-checkbox'][$id]) ? $_POST['wcam-customer-approve-checkbox'][$id] : "no";
                 $file_order_metadata[$id]['customer-can-reapprove'] = isset($_POST['wcam-customer-reapprove-checkbox'][$id]) ? $_POST['wcam-customer-reapprove-checkbox'][$id] : "no";
                 $file_order_metadata[$id]['customer-feedback-enabled'] = isset($_POST['wcam-customer-feedback-checkbox'][$id]) ? $_POST['wcam-customer-feedback-checkbox'][$id] : "no";
                 $file_order_metadata[$id]['customer-admin-notification'] = isset($_POST['wcam-customer-admin-notification-checkbox'][$id]) ? $_POST['wcam-customer-admin-notification-checkbox'][$id] : "no";
                 $file_order_metadata[$id]['attach-file-to-processing-order-email'] = isset($_POST['wcam-attach-file-to-processing-order-email'][$id]) ? $_POST['wcam-attach-file-to-processing-order-email'][$id] : "no";
                 $file_order_metadata[$id]['attach-file-to-complete-order-email'] = isset($_POST['wcam-attach-file-to-complete-order-email'][$id]) ? $_POST['wcam-attach-file-to-complete-order-email'][$id] : "no";
                 $file_order_metadata[$id]['attach-file-to-customer-invoice-email'] = isset($_POST['wcam-attach-file-to-customer-invoice-email'][$id]) ? $_POST['wcam-attach-file-to-customer-invoice-email'][$id] : "no";
                 //var_dump($file_order_metadata[$id]);
             } else {
                 //var_dump($movefile['error']);
             }
         }
     }
     //update_post_meta( $order_id, '_wcam_attachments_meta', $file_order_metadata);
     return $file_order_metadata;
 }
Example #3
0
    private function render_options_page()
    {
        $option = new WCAM_Option();
        if (isset($_POST['wcam_general_options'])) {
            $option->save_options($_POST['wcam_general_options']);
        }
        $options = $option->get_option();
        //get_option( 'wcam_general_options');
        //wcam_var_dump(get_option( 'wcam_general_options'));
        wp_enqueue_style('wcam-options-page', plugin_dir_url(__FILE__) . 'css/wcam-backend-options.css');
        $default_width = get_option('thumbnail' . '_size_w');
        $default_height = get_option('thumbnail' . '_size_h');
        $wpml = new WCAM_Wpml();
        $curr_lang = $wpml->get_current_language();
        ?>
		<div class="wrap">
			<h2><?php 
        _e('Options page', 'woocommerce-customers-manager');
        ?>
</h2>
			<!--<form method="post" action="options.php">-->
			<form method="post"  action="">
			<?php 
        //settings_fields('wcam_general_options_group');
        ?>
 
			<div id="options-container">
				<h3><?php 
        _e('General', 'woocommerce-customers-manager');
        ?>
</h3>
				
				<p>
				<label><?php 
        _e('Folder name (use only alphanumeric characters, NO special characters allowed). Previous attachments will not be moved to the new folder', 'woocommerce-customers-manager');
        ?>
</label>
				<input type="text" name="wcam_general_options[folder_name]" value="<?php 
        if (isset($options['folder_name'])) {
            echo $options['folder_name'];
        } else {
            echo "wcam";
        }
        ?>
" required></input><br/>
				<small><?php 
        _e('Upload folder is located in wp-content/uploads/ folder.', 'woocommerce-customers-manager');
        ?>
</small>
				</p>
				<label><?php 
        _e('Chose which options are "on" by default', 'woocommerce-customers-manager');
        ?>
</label>
				<input type="checkbox" <?php 
        if (isset($options['approve_checkbox_default_value']) && $options['approve_checkbox_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
 
					   name="wcam_general_options[approve_checkbox_default_value]" class="wcam-customer-approve-checkbox" value="yes"><?php 
        _e('Let customer approves? ', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				<input type="checkbox" <?php 
        if (isset($options['reapprove_checkbox_default_value']) && $options['reapprove_checkbox_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
 
					   name="wcam_general_options[reapprove_checkbox_default_value]" class="wcam-customer-reapprove-checkbox" value="yes"><?php 
        _e('Can customer change approval value after submit?', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				<input type="checkbox" <?php 
        if (isset($options['feedback_checkbox_default_value']) && $options['feedback_checkbox_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
						name="wcam_general_options[feedback_checkbox_default_value]"  class="wcam-customer-feedback-checkbox" value="yes"><?php 
        _e('Let customer leave a text feedback?', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				<input type="checkbox" <?php 
        if (isset($options['customer_admin_notification_checkbox_default_value']) && $options['customer_admin_notification_checkbox_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
					   name="wcam_general_options[customer_admin_notification_checkbox_default_value]" class="wcam-customer-admin-notification-checkbox" value="yes"><?php 
        _e('Receive an email when the customer approve or leaves a feedback? ', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				<input type="checkbox" <?php 
        if (isset($options['attach_file_to_processing_order_email_default_value']) && $options['attach_file_to_processing_order_email_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
					   class="wcam-attach-file-to-complete-order-email" name="wcam_general_options[attach_file_to_processing_order_email_default_value]"  value="yes"><?php 
        _e('Attach file to the Processing order email', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				<input type="checkbox" <?php 
        if (isset($options['attach_file_to_complete_order_email_default_value']) && $options['attach_file_to_complete_order_email_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
					   class="wcam-attach-file-to-complete-order-email" name="wcam_general_options[attach_file_to_complete_order_email_default_value]"  value="yes"><?php 
        _e('Attach file to the Complete order email', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				<input type="checkbox" <?php 
        if (isset($options['attach_file_to_customer_invoice_email_default_value']) && $options['attach_file_to_customer_invoice_email_default_value'] == 'yes') {
            echo 'checked="checked"';
        }
        ?>
					   class="wcam-attach-file-to-complete-order-email" name="wcam_general_options[attach_file_to_customer_invoice_email_default_value]"  value="yes"><?php 
        _e('Attach file to the Customer Invoice email', 'woocommerce-attach-me');
        ?>
</input>
				<br/>
				
				<h3><?php 
        _e('Texts', 'woocommerce-customers-manager');
        ?>
</h3>
				<?php 
        if ($wpml->is_wpml_active()) {
            ?>
					<small><strong><?php 
            _e('NOTE:', 'woocommerce-customers-manager');
            ?>
</strong> <?php 
            _e('WPML Detected! to translate following texts simply select the language you desire from the upper WPML language selector, edit texts and save!', 'woocommerce-customers-manager');
            ?>
 </small>
				<?php 
        }
        ?>
				<h4><?php 
        _e('Order details page', 'woocommerce-customers-manager');
        ?>
</h4>				
				<p>
				<label><?php 
        _e('Attachments section title', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[title_box][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['title_box'][$curr_lang])) {
            echo $options['title_box'][$curr_lang];
        } else {
            _e('Attachments', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<p>
					<label><?php 
        _e('Download / View button', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[download_view_button_text][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['download_view_button_text'][$curr_lang])) {
            echo $options['download_view_button_text'][$curr_lang];
        } else {
            _e('Download / View', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<p>
					<label><?php 
        _e('Approval box title', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[approve_box_title][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['approve_box_title'][$curr_lang])) {
            echo $options['approve_box_title'][$curr_lang];
        } else {
            _e('Do you approve?', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<p>
					<label><?php 
        _e('Approval already sent message', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[approve_already_sent_message][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['approve_already_sent_message'][$curr_lang])) {
            echo $options['approve_already_sent_message'][$curr_lang];
        } else {
            _e('Approvation already sent. Selected value was:', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<p>
					<label><?php 
        _e('Approval options', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[approve_not_yet_text][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['approve_not_yet_text'][$curr_lang])) {
            echo $options['approve_not_yet_text'][$curr_lang];
        } else {
            _e('Not yet', 'woocommerce-attach-me');
        }
        ?>
" required></input><br/>
					<input type="text" name="wcam_general_options[approve_yes_text][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['approve_yes_text'][$curr_lang])) {
            echo $options['approve_yes_text'][$curr_lang];
        } else {
            _e('Yes', 'woocommerce-attach-me');
        }
        ?>
" required></input><br/>
					<input type="text" name="wcam_general_options[approve_no_text][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['approve_no_text'][$curr_lang])) {
            echo $options['approve_no_text'][$curr_lang];
        } else {
            _e('No', 'woocommerce-attach-me');
        }
        ?>
" required></input><br/>
				</p>
				<p>
					<label><?php 
        _e('Feedback section title', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[feedback_box_title][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['feedback_box_title'][$curr_lang])) {
            echo $options['feedback_box_title'][$curr_lang];
        } else {
            _e('Please enter a feedback', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<h4><?php 
        _e('Emails', 'woocommerce-customers-manager');
        ?>
</h4>
				<p>
					<label><?php 
        _e('Customer approval section title', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[email_approve_box_title][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['email_approve_box_title'][$curr_lang])) {
            echo $options['email_approve_box_title'][$curr_lang];
        } else {
            _e('Customer has approved?', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<p>
					<label><?php 
        _e('Customer feedback section title', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[email_feedback_box_title][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['email_feedback_box_title'][$curr_lang])) {
            echo $options['email_feedback_box_title'][$curr_lang];
        } else {
            _e('Customer feedback', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				<p>
					<label><?php 
        _e('No customer feedback message', 'woocommerce-customers-manager');
        ?>
</label>
					<input type="text" name="wcam_general_options[email_no_customer_feedback_message][<?php 
        echo $curr_lang;
        ?>
]" value="<?php 
        if (isset($options['email_no_customer_feedback_message'][$curr_lang])) {
            echo $options['email_no_customer_feedback_message'][$curr_lang];
        } else {
            _e('No customer feedback', 'woocommerce-attach-me');
        }
        ?>
"></input>
				</p>
				
				
				
				<h3><?php 
        _e('Style', 'woocommerce-customers-manager');
        ?>
</h3>
				<p>
				<label><?php 
        _e('Approval option list style (You can select to display approval options using a select box or a radio buttons)', 'woocommerce-customers-manager');
        ?>
</label>
				<select  name="wcam_general_options[approval_box_style]">
					<option value="select" <?php 
        if (!isset($options['approval_box_style']) || $options['approval_box_style'] == 'select') {
            echo 'selected';
        }
        ?>
>Select</option>
					<option value="radio" <?php 
        if (isset($options['approval_box_style']) && $options['approval_box_style'] == 'radio') {
            echo 'selected';
        }
        ?>
>Radio</option>
				</select>
				</p>
				<p>
				<label><?php 
        _e('Display image preview (only if attachment is an image)', 'woocommerce-customers-manager');
        ?>
</label>
				<select  name="wcam_general_options[dispaly_image_preview]">
					<option value="no" <?php 
        if (!isset($options['dispaly_image_preview']) || $options['dispaly_image_preview'] == 'no') {
            echo 'selected';
        }
        ?>
><?php 
        _e('No', 'woocommerce-customers-manager');
        ?>
</option>
					<option value="yes" <?php 
        if (isset($options['dispaly_image_preview']) && $options['dispaly_image_preview'] == 'yes') {
            echo 'selected';
        }
        ?>
><?php 
        _e('Yes', 'woocommerce-customers-manager');
        ?>
</option>
				</select>
				</p>
				<p>
				<label><?php 
        _e('Thumb  width (by default is used the one setted in "Settings" -> "Media" option)', 'woocommerce-customers-manager');
        ?>
</label>
				<input type="number" min="0" name="wcam_general_options[thumb_width]"value="<?php 
        if (isset($options['thumb_width'])) {
            echo $options['thumb_width'];
        } else {
            echo $default_width;
        }
        ?>
" ></input>
				</p>
				<label><?php 
        _e('Thumb  heigth (by default is used the one setted in "Settings" -> "Media" option)', 'woocommerce-customers-manager');
        ?>
</label>
				<input type="number" min="0" name="wcam_general_options[thumb_height]"value="<?php 
        if (isset($options['thumb_height'])) {
            echo $options['thumb_height'];
        } else {
            echo $default_height;
        }
        ?>
" ></input>
				</p>
						
				<input name="Submit" type="submit" class="button-primary" value="<?php 
        esc_attr_e('Save Changes', 'woocommerce-customers-manager');
        ?>
" />
				</p>
			</div>
			</form>
		</div>
		<?php 
    }