/**
  * Shows an avatar of the lead.
  * 
  * @since 1.0.7
  * @return void
  */
 public function column_avatar($record)
 {
     $url = admin_url('/edit.php?post_type=opanda-item&page=leads-bizpanda&action=leadDetails&leadID=' . $record->ID);
     $avatar = '';
     if (!empty($url)) {
         $avatar .= '<a href="' . $url . '" class="opanda-avatar">';
     } else {
         $avatar .= '<span class="opanda-avatar">';
     }
     $avatar .= OPanda_Leads::getAvatar($record->ID, $record->lead_email, 40);
     if (!empty($url)) {
         $avatar .= '</a>';
     } else {
         $avatar .= '</span>';
     }
     echo $avatar;
 }
Beispiel #2
0
    public function leadDetailsAction()
    {
        $leadId = isset($_REQUEST['leadID']) ? intval($_REQUEST['leadID']) : 0;
        $lead = OPanda_Leads::get($leadId);
        $customFields = OPanda_Leads::getCustomFields($leadId);
        $email = $lead->lead_email;
        $name = $lead->lead_name;
        $family = $lead->lead_family;
        if (!empty($name) || !empty($family)) {
            $displayName = $name . ' ' . $family;
        } else {
            $displayName = !empty($lead->lead_display_name) ? $lead->lead_display_name : $lead->lead_email;
        }
        $emailConfirmed = empty($lead->lead_email_confirmed) ? 0 : 1;
        $subscriptionConfirmed = empty($lead->lead_subscription_confirmed) ? 0 : 1;
        if (isset($_POST['submit'])) {
            $data = array();
            $email = $_POST['email'];
            if (!filter_var($email, FILTER_VALIDATE_EMAIL) || !preg_match('/@.+\\./', $email)) {
                $error = __('Please enter a valid email.', 'bizpanda');
            } else {
                $name = $_POST['name'];
                $family = $_POST['family'];
                if (!empty($name) || !empty($family)) {
                    $displayName = $name . ' ' . $family;
                } else {
                    $displayName = !empty($lead->lead_display_name) ? $lead->lead_display_name : $lead->lead_email;
                }
                $data['email'] = $email;
                $data['displayName'] = $displayName;
                $data['name'] = $name;
                $data['family'] = $family;
                $emailConfirmed = empty($_POST['email_confirmed']) ? 0 : 1;
                $subscriptionConfirmed = empty($_POST['subscription_confirmed']) ? 0 : 1;
                $customValues = isset($_POST['opanda_values']) ? $_POST['opanda_values'] : array();
                $customNames = isset($_POST['opanda_names']) ? $_POST['opanda_names'] : array();
                $index = 0;
                foreach ($customNames as $customName) {
                    $data['{' . $customName . '}'] = $customValues[$index];
                    $customFields[$customName] = $customValues[$index];
                    $index++;
                }
                OPanda_Leads::save($lead, $data, array(), $emailConfirmed, $subscriptionConfirmed);
                $url = admin_url('/edit.php?post_type=opanda-item&page=leads-bizpanda&action=leadDetails&leadID=' . $lead->ID . '&opanda_success=1');
                wp_redirect($url);
                exit;
            }
        }
        $avatar = OPanda_Leads::getAvatar($leadId, $lead->lead_email, 150);
        $postUrl = admin_url('/edit.php?post_type=opanda-item&page=leads-bizpanda&action=leadDetails&leadID=' . $lead->ID);
        $cancelUrl = admin_url('/edit.php?post_type=opanda-item&page=leads-bizpanda');
        ?>

        <div class="wrap factory-fontawesome-320" id="opanda-lead-details-page">
            
        <h2>Edit <strong><?php 
        echo $displayName;
        ?>
</strong></h2>
        
        <?php 
        if (isset($_GET['opanda_success'])) {
            ?>
        <div class="factory-bootstrap-329">
            <div class="alert alert-success"><?php 
            _e('<strong>Well done!</strong> The lead data updated successfully.', 'bizpanda');
            ?>
</div>
        </div>
        <?php 
        }
        ?>
        
        <?php 
        if (!empty($error)) {
            ?>
        <div class="factory-bootstrap-329">
            <div class="alert alert-danger"><?php 
            echo $error;
            ?>
</div>
        </div>
        <?php 
        }
        ?>
        
        <form method="POST" action="<?php 
        echo $postUrl;
        ?>
">
            <input type="hidden" name="leadID" value="<?php 
        echo $leadId;
        ?>
" />
            <input type="hidden" name="submit" value="1" />
            
        <table class="form-table">
            <tr>
                <td scope="row" class="avatar-wrap">
                    <div class="opanda-avatar"><?php 
        echo $avatar;
        ?>
</div>
                </td>
                
                <td class="user-info">
                    
                    <h3 class="detail">
                        <ul class="click-to-edit">
                            <li><?php 
        echo $email;
        ?>
</li>
                            <li><input id="opanda_email" class="" type="text" name="email" value="<?php 
        echo $email;
        ?>
" placeholder="<?php 
        _e('Email', 'bizpanda');
        ?>
"></li>
                        </ul>
                    </h3>
                    
                    <div class="detail">
                        <label for="opanda_name"><?php 
        _e('Name:', 'bizpanda');
        ?>
</label>
                        <ul class="click-to-edit">
                            <li><?php 
        echo $name;
        ?>
 <?php 
        echo $family;
        ?>
</li>
                            <li>
                                <input id="opanda_name" type="text" name="name" value="<?php 
        echo $name;
        ?>
" placeholder="<?php 
        _e('First Name', 'bizpanda');
        ?>
">
                                <input id="opanda_family" class="" type="text" name="family" value="<?php 
        echo $family;
        ?>
" placeholder="<?php 
        _e('Last Name', 'bizpanda');
        ?>
">
                            </li>
                        </ul>
                    </div>
                    
                    <div class="detail">
                        <label for="opanda_email_confirmed"><?php 
        _e('Email Confirmed:', 'bizpanda');
        ?>
</label>
                        <ul class="click-to-edit">
                            <li><?php 
        if ($emailConfirmed) {
            _e('yes', 'bizpanda');
        } else {
            _e('no', 'bizpanda');
        }
        ?>
</li>
                            <li>
                                <input type="checkbox" id="opanda_email_confirmed" name="email_confirmed" value="1" <?php 
        if ($emailConfirmed) {
            echo 'checked="checked"';
        }
        ?>
 >            
                            </li>
                        </ul>
                    </div>
                    
                    <?php 
        if (BizPanda::hasPlugin('optinpanda')) {
            ?>
                    
                    <div class="detail">
                        <label for="opanda_subscription_confirmed"><?php 
            _e('Subscription Confirmed:', 'bizpanda');
            ?>
</label>
                        <ul class="click-to-edit">
                            <li><?php 
            if ($subscriptionConfirmed) {
                _e('yes', 'bizpanda');
            } else {
                _e('no', 'bizpanda');
            }
            ?>
</li>
                            <li>
                                <input type="checkbox" id="opanda_email_confirmed" name="subscription_confirmed" value="1" <?php 
            if ($subscriptionConfirmed) {
                echo 'checked="checked"';
            }
            ?>
 >                
                            </li>
                        </ul>
                    </div>
                    
                    <?php 
        }
        ?>
                    
                    <?php 
        if (!empty($customFields)) {
            ?>
                    
                    <div class="custom-field-wrap">
                        
                    <?php 
            $index = 0;
            foreach ($customFields as $fieldName => $fieldValue) {
                $index++;
                ?>
                    
                        <div class="detail">
                            <label for="opanda_<?php 
                echo $index;
                ?>
"><?php 
                echo $fieldName;
                ?>
:</label>

                            <ul class="click-to-edit">
                                <li><?php 
                echo $fieldValue;
                ?>
</li>
                                <li><input type="text" id="opanda_<?php 
                echo $index;
                ?>
" name="opanda_values[]" value="<?php 
                echo $fieldValue;
                ?>
" class="regular-text input"></li>
                                <input type="hidden" name="opanda_names[]" value="<?php 
                echo $fieldName;
                ?>
" />
                            </ul>
                        </div>
                    
                    <?php 
            }
            ?>
                        
                    </div>
                    
                    <?php 
        }
        ?>

                    <div class="controls-wrap">
                        <input type="submit" class="button button-primary" value="<?php 
        _e('Save Changes', 'bizpanda');
        ?>
" />
                        <a href="<?php 
        echo $cancelUrl;
        ?>
" class="button button-default"><?php 
        _e('Return', 'bizpanda');
        ?>
</a> 
                    </div>
                </td>

            </tr>
        </table>
            
        </form>
        
        </div>
        
        <?php 
    }