Plugin Directory

Changeset 1787929


Ignore:
Timestamp:
12/16/2017 09:03:37 AM (8 years ago)
Author:
eewee
Message:

v1.1

Location:
eewee-sellsy/trunk
Files:
10 added
15 edited

Legend:

Unmodified
Added
Removed
  • eewee-sellsy/trunk/changelog

    r1652294 r1787929  
     1= 1.1 =
     2* Create table version and update version auto
     3
     4= 1.0.14 =
     5* Add CF SimpleText
     6
     7= 1.0.13 =
     8* Add tracking
     9
     10= 1.0.12 =
     11* Url http / https
     12
    113= 1.0.11 =
    214* Wording
  • eewee-sellsy/trunk/controllers/AdminController.php

    r1610848 r1787929  
    2727
    2828        }
     29
     30        /**
     31         * execute during update plugin
     32         */
     33//        function eewee_update()
     34//        {
     35//
     36//        }
    2937               
    3038        /**
  • eewee-sellsy/trunk/controllers/InstallController.php

    r1638551 r1787929  
    1818        // - https://codex.wordpress.org/Function_Reference/current_time
    1919        // - echo current_time( 'mysql', 1 ).'<br>'; // 0: GMT+1, 1: GMT+0
     20
     21        // BO - VERSION
     22        $sql[] = "
     23            CREATE TABLE `".EEWEE_SELLSY_PREFIXE_BDD."version` (
     24              `version_id` int(11) NOT NULL AUTO_INCREMENT,
     25              `version_value` float(11) NOT NULL,
     26              PRIMARY KEY (`version_id`)
     27            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
     28            ";
    2029
    2130        // BO - SETTING
     
    106115             
    107116              `contact_form_status` tinyint(1) NOT NULL,
     117             
     118              `contact_form_custom_fields_quantity` int(11) NOT NULL,
     119              `contact_form_custom_fields_value` text NOT NULL,
    108120              PRIMARY KEY (`contact_form_id`)
    109121            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
     
    126138
    127139        $sql[] = "
     140            INSERT INTO `".EEWEE_SELLSY_PREFIXE_BDD."version` VALUES (1, '".EEWEE_VERSION."');
     141            ";
     142
     143        $sql[] = "
    128144            INSERT INTO `".EEWEE_SELLSY_PREFIXE_BDD."setting` VALUES (1, '".current_time('mysql')."', '".current_time('mysql')."', '', '', '', '', '', '', '');
    129145            ";
     
    135151        for( $i=1; $i<=25; $i++ ){
    136152            $sql[] = "
    137                 INSERT INTO `" . EEWEE_SELLSY_PREFIXE_BDD . "contact_form` VALUES (".$i.", '" . current_time('mysql') . "', '" . current_time('mysql') . "', 'Contact ".$i."', '0', 'Website form ".$i."', '0', '0', '0', '" . get_bloginfo('admin_email') . "', '1', '1', '1', '1', '0', '0', '0', '1', '1', '1', '0', '0', '0');
     153                INSERT INTO `" . EEWEE_SELLSY_PREFIXE_BDD . "contact_form` VALUES (".$i.", '" . current_time('mysql') . "', '" . current_time('mysql') . "', 'Contact ".$i."', '0', 'Website form ".$i."', '0', '0', '0', '" . get_bloginfo('admin_email') . "', '1', '1', '1', '1', '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '');
    138154            ";
    139155        }
     
    147163     */
    148164    public function delete(){
    149         //echo "DELETE PLUGIN<br>";
    150165        global $wpdb;
     166        $sql[] = "DROP TABLE  `".EEWEE_SELLSY_PREFIXE_BDD."version`";
    151167        $sql[] = "DROP TABLE  `".EEWEE_SELLSY_PREFIXE_BDD."setting`";
    152168        $sql[] = "DROP TABLE  `".EEWEE_SELLSY_PREFIXE_BDD."ticket`";
  • eewee-sellsy/trunk/controllers/ShortcodeController.php

    r1652294 r1787929  
    2525            $render     = '';
    2626            $error      = array();
    27             $styleError = 'style="border:1px solid red;"'; // :(
     27            $classError = 'border-error';
     28            $decode     = array("success"=>false);
    2829            $messageForm = '';
    2930            $form_ticket_support_subject    = '';
     
    7879                if (empty($form_ticket_support_email)) {
    7980                    $error[] = __('email', PLUGIN_NOM_LANG);
    80                     $class_ticket_support_email = $styleError;
     81                    $class_ticket_support_email = $classError;
    8182                }
    8283                if (empty($form_ticket_support_lastname)) {
    8384                    $error[] = __('name', PLUGIN_NOM_LANG);
    84                     $class_ticket_support_name = $styleError;
     85                    $class_ticket_support_name = $classError;
    8586                }
    8687                if (empty($form_ticket_support_message)) {
    8788                    $error[] = __('message', PLUGIN_NOM_LANG);
    88                     $class_ticket_support_message = $styleError;
     89                    $class_ticket_support_message = $classError;
    8990                }
    9091                if ($reCaptchaOkOrNot === false && $setting[0]->setting_recaptcha_key_status == 0) {
    9192                    $error[] = __('reCAPTCHA', PLUGIN_NOM_LANG);
    92                     $class_ticket_support_recaptcha = $styleError;
     93                    $class_ticket_support_recaptcha = $classError;
    9394                }
    9495
     
    182183                   
    183184                    <label>'.__('Email', PLUGIN_NOM_LANG).' *</label>
    184                     <input type="email" name="form_ticket_support_email" value="'.$form_ticket_support_email.'" id="form_ticket_support_email" '.$class_ticket_support_email.'>
     185                    <input type="email" name="form_ticket_support_email" value="'.$form_ticket_support_email.'" id="form_ticket_support_email" class=
     186                     "'.$class_ticket_support_email.'">
    185187                   
    186188                    <label>'.__('Name', PLUGIN_NOM_LANG).' *</label>
    187                     <input type="text" name="form_ticket_support_lastname" value="'.$form_ticket_support_lastname.'" id="form_ticket_support_lastname" '.$class_ticket_support_name.'> 
     189                    <input type="text" name="form_ticket_support_lastname" value="'.$form_ticket_support_lastname.'" id="form_ticket_support_lastname" class=
     190                     "'.$class_ticket_support_name.'"> 
    188191                   
    189192                    <label>'.__('Message', PLUGIN_NOM_LANG).' *</label>
    190                     <textarea name="form_ticket_support_message" id="form_ticket_support_message" '.$class_ticket_support_message.'>'.$form_ticket_support_message.'</textarea>';
     193                    <textarea name="form_ticket_support_message" id="form_ticket_support_message" class=
     194                     "'.$class_ticket_support_message.'">'.$form_ticket_support_message.'</textarea>';
    191195
    192196                    // reCaptcha : cle du site
     
    197201                    ) {
    198202                        $render .= '
    199                         <div class="g-recaptcha" data-sitekey="'.$setting[0]->setting_recaptcha_key_website.'" '.$class_ticket_support_recaptcha.'></div>';
     203                        <div class="g-recaptcha" data-sitekey="'.$setting[0]->setting_recaptcha_key_website.'" class=
     204                     "'.$class_ticket_support_recaptcha.'"></div>';
    200205                    }
    201206
     
    215220         */
    216221        public function contactSellsy( $atts='' )  {
     222
    217223            // INIT
    218224            $id         = '';
    219225            $render     = '';
    220226            $error      = array();
    221             $styleError = 'style="border:1px solid red;"'; // :(
     227            $classError = 'border-error';
    222228            $messageForm = '';
    223229            // form
     
    322328                } else {
    323329                    $api_third['type'] = 'person'; // corporation/person
    324                    
     330
    325331                    if (isset($_POST['contact_form_contact_lastname'])) {
    326332                        $api_third['name'] = sanitize_text_field($_POST['contact_form_contact_lastname']);
     
    366372                if (empty($api_contact['name'])) {
    367373                    $error[] = __('lastname', PLUGIN_NOM_LANG);
    368                     $tbl_class['class_contact_form_contact_lastname'] = $styleError.' required';
     374                    $tbl_class['class_contact_form_contact_lastname'] = $classError;
    369375                }
    370376                if (empty($api_contact['email'])) {
    371377                    $error[] = __('email', PLUGIN_NOM_LANG);
    372                     $tbl_class['class_contact_form_contact_email'] = $styleError.' required';
     378                    $tbl_class['class_contact_form_contact_email'] = $classError;
    373379                }
    374380                if ($reCaptchaOkOrNot === false && $setting[0]->setting_recaptcha_key_status == 0) {
    375381                    $error[] = __('reCAPTCHA', PLUGIN_NOM_LANG);
    376                     $class_ticket_support_recaptcha = $styleError;
    377                 }
    378 
     382                    $class_ticket_support_recaptcha = $classError;
     383                }
     384
     385
     386
     387
     388                // CF
     389                if (isset($_POST['form_cf'])) {
     390                    foreach ($_POST['form_cf'] as $k=>$v) {
     391
     392                        // CF : SIMPLETEXT
     393                        if (isset($v['simpletext'])) {
     394
     395                            // DATAS
     396                            $d['api']['id'] = $k;
     397                            $d['api']['label'] = $v['simpletext']['name'];
     398                            $d['api']['default'] = $v['simpletext']['default'];
     399                            $d['api']['min'] = $v['simpletext']['min'];
     400                            $d['api']['max'] = $v['simpletext']['max'];
     401                            $d['api']['useOne_prospect'] = $v['simpletext']['useOn_prospect'];
     402                            $d['api']['useOne_opportunity'] = $v['simpletext']['useOn_opportunity'];
     403                            $d['form']['value'] = $v['simpletext']['value'];
     404
     405                            // PROCESSING
     406                            $cf_obj     = new SellsyCustomFieldsController();
     407                            $checkCf    = $cf_obj->checkSimpleText($d);
     408
     409                            if (isset($checkCf[0]) && $checkCf[0] == "error") {
     410                                $error[] = $d['api']['label'].' ('.$checkCf[1].')';
     411                                $tbl_class[$d['api']['id']] = $classError;
     412                            }
     413                        }
     414                    }
     415                }
    379416
    380417
     
    410447                    if ($response->status == 'success') {
    411448
     449                        // INSERT TO SELLSY : CF Prospect
     450                        $cfSave = new SellsyCustomFieldsController();
     451                        $cfSave->dataProcessing($_POST, array("id"=>$linkedid,"type"=>"prospect"));
     452
     453
     454
     455
     456                        // INSERT TO SELLSY : TRACKING
     457                        // get
     458                        $c = new CookieController();
     459                        $cDatas = $c->datasForTracking();
     460                        // save
     461                        $t = new models\TSellsyTracking();
     462                        $t->record(array(
     463                            'thirdid' => $tbl_contact['linkedid'],
     464                            'datas'   => $cDatas,
     465                        ));
     466                        // clean (for next page load). Why : cookie not change in shortcode
     467                        echo '
     468                        <script type="text/javascript">
     469                            localStorage.setItem("cookieClean", "y");
     470                        </script>';
     471
     472
     473
     474
    412475                        // NOTIFICATION EMAIL
    413476                        if (isset($contact[0]->contact_form_setting_notification_email)) {
     
    427490                        // OPTION SELECTED : prospect and opportunity
    428491                        if ($contact[0]->contact_form_setting_add_what == 1 && isset($tbl_contact['linkedid'])) {
    429                             // CREATE OPPORTUNITY
     492                            // INSERT TO SELLSY : OPPORTUNITY
    430493                            $t_sellsyOpportunities = new models\TSellsyOpportunities();
    431494                            $responseOpp = $t_sellsyOpportunities->create(array(
     
    440503                            if ($responseOpp->status == 'success') {
    441504
    442                                 // ...
     505                                // INSERT TO SELLSY : CF Opportunity
     506                                $cfSave = new SellsyCustomFieldsController();
     507                                $cfSave->dataProcessing($_POST, array("id"=>$responseOpp->response,"type"=>"opportunity"));
    443508
    444509                            // API : error
     
    473538                        );
    474539                        $messageForm = '<div class="eewee-success-message">'.__('Thank you for your message, it has been sent.', PLUGIN_NOM_LANG).'</div>';
     540                        //$messageForm = '<div class="eewee-success-message">'.__('Thank you for your message, it has been sent.', PLUGIN_NOM_LANG).' - linkedid:'.$tbl_contact['linkedid'].' - <pre>'.var_export($cDatas, true).'</pre> - '.$responseOpp->status.'</div>';
    475541
    476542                    // API : error
     
    491557                    <div class="eewee-error-message eewee-contact eewee-contact-'.$contact[0]->contact_form_id.'">
    492558                        <strong>';
    493                     if (sizeof($error) == 1) {
    494                         $render .= __('A field contains an error.', PLUGIN_NOM_LANG).'<br>';
    495                         $render .= __('Please check and try again', PLUGIN_NOM_LANG);
    496                     } else {
    497                         $render .= __('Several fields contain an error.', PLUGIN_NOM_LANG).'<br>';
    498                         $render .= __('Please check and try again', PLUGIN_NOM_LANG);
    499                     }
    500                     $render .= '
    501                          : </strong><br>'.implode(', ', $error).'.
     559                        if (sizeof($error) == 1) {
     560                            $render .= __('A field contains an error.', PLUGIN_NOM_LANG).'<br>';
     561                            $render .= __('Please check and try again', PLUGIN_NOM_LANG);
     562                        } else {
     563                            $render .= __('Several fields contain an error.', PLUGIN_NOM_LANG).'<br>';
     564                            $render .= __('Please check and try again', PLUGIN_NOM_LANG);
     565                        }
     566                        $render .= '
     567                         : </strong><br><ul><li>'.implode('</li><li>', $error).'</li></ul>
    502568                     </div>';
    503569                }
    504570            }
     571
     572
     573
    505574
    506575            // FORM (setting = online)
     
    519588                        $render .= '
    520589                        <label>'.__('Company name', PLUGIN_NOM_LANG).'</label>
    521                         <input type="text" name="contact_form_company_name" value="'.$api_third['name'].'" id="contact_form_company_name">';
     590                        <input type="text" name="contact_form_company_name" value="'.$api_third['name'].'" id="contact_form_company_name" class="'.$tbl_class['class_contact_form_contact_name'].'">';
    522591                    }
    523592                    if ($contact[0]->contact_form_company_siren == 0) {
    524593                        $render .= '
    525594                        <label>'.__('Siren', PLUGIN_NOM_LANG).'</label>
    526                         <input type="text" name="contact_form_company_siren" value="'.$api_third['siren'].'" id="contact_form_company_siren">';
     595                        <input type="text" name="contact_form_company_siren" value="'.$api_third['siren'].'" id="contact_form_company_siren" class="'.$tbl_class['class_contact_form_contact_siren'].'">';
    527596                    }
    528597                    if ($contact[0]->contact_form_company_siret == 0) {
    529598                        $render .= '
    530599                        <label>'.__('Siret', PLUGIN_NOM_LANG).'</label>
    531                         <input type="text" name="contact_form_company_siret" value="'.$api_third['siret'].'" id="contact_form_company_siret">';
     600                        <input type="text" name="contact_form_company_siret" value="'.$api_third['siret'].'" id="contact_form_company_siret" class="'.$tbl_class['class_contact_form_contact_siret'].'">';
    532601                    }
    533602                    if ($contact[0]->contact_form_company_rcs == 0) {
    534603                        $render .= '
    535604                        <label>'.__('RCS', PLUGIN_NOM_LANG).'</label>
    536                         <input type="text" name="contact_form_company_rcs" value="'.$api_third['rcs'].'" id="contact_form_company_rcs">';
     605                        <input type="text" name="contact_form_company_rcs" value="'.$api_third['rcs'].'" id="contact_form_company_rcs" class="'.$tbl_class['class_contact_form_contact_rcs'].'">';
    537606                    }
    538607
     
    541610                        $render .= '
    542611                        <label>'.__('Lastname', PLUGIN_NOM_LANG).' *</label>
    543                         <input type="text" name="contact_form_contact_lastname" value="'.$api_contact['name'].'" id="contact_form_contact_lastname" '.$tbl_class['class_contact_form_contact_lastname'].'>';
     612                        <input type="text" name="contact_form_contact_lastname" value="'.$api_contact['name'].'" id="contact_form_contact_lastname" class="'.$tbl_class['class_contact_form_contact_lastname'].'" required>';
    544613                    }
    545614                    if ($contact[0]->contact_form_contact_firstname == 0) {
    546615                        $render .= '
    547616                        <label>'.__('Firstname', PLUGIN_NOM_LANG).'</label>
    548                         <input type="text" name="contact_form_contact_firstname" value="'.$api_contact['forename'].'" id="contact_form_contact_firstname">';
     617                        <input type="text" name="contact_form_contact_firstname" value="'.$api_contact['forename'].'" id="contact_form_contact_firstname" class="'.$tbl_class['class_contact_form_contact_firstname'].'">';
    549618                    }
    550619                    if ($contact[0]->contact_form_contact_email == 0) {
    551620                        $render .= '
    552621                        <label>'.__('Email', PLUGIN_NOM_LANG).' *</label>
    553                         <input type="email" name="contact_form_contact_email" value="'.$api_contact['email'].'" id="contact_form_contact_email" '.$tbl_class['class_contact_form_contact_email'].'>';
     622                        <input type="email" name="contact_form_contact_email" value="'.$api_contact['email'].'" id="contact_form_contact_email" class="'.$tbl_class['class_contact_form_contact_email'].'" required>';
    554623                    }
    555624                    if ($contact[0]->contact_form_contact_phone_1 == 0) {
    556625                        $render .= '
    557626                        <label>'.__('Phone', PLUGIN_NOM_LANG).'</label>
    558                         <input type="text" name="contact_form_contact_phone_1" value="'.$api_contact['tel'].'" id="contact_form_contact_phone_1">';
     627                        <input type="text" name="contact_form_contact_phone_1" value="'.$api_contact['tel'].'" id="contact_form_contact_phone_1" class="'.$tbl_class['class_contact_form_contact_phone_1'].'">';
    559628                    }
    560629                    if ($contact[0]->contact_form_contact_phone_2 == 0) {
    561630                        $render .= '
    562631                        <label>'.__('Mobile', PLUGIN_NOM_LANG).'</label>
    563                         <input type="text" name="contact_form_contact_phone_2" value="'.$api_contact['mobile'].'" id="contact_form_contact_phone_2">';
     632                        <input type="text" name="contact_form_contact_phone_2" value="'.$api_contact['mobile'].'" id="contact_form_contact_phone_2" class="'.$tbl_class['class_contact_form_contact_phone_2'].'">';
    564633                    }
    565634                    if ($contact[0]->contact_form_contact_function == 0) {
    566635                        $render .= '
    567636                        <label>'.__('Function', PLUGIN_NOM_LANG).'</label>
    568                         <input type="text" name="contact_form_contact_function" value="'.$api_contact['position'].'" id="contact_form_contact_function">';
     637                        <input type="text" name="contact_form_contact_function" value="'.$api_contact['position'].'" id="contact_form_contact_function" class="'.$tbl_class['class_contact_form_contact_function'].'">';
    569638                    }
    570639
     
    573642                        $render .= '
    574643                        <label>'.__('website', PLUGIN_NOM_LANG).'</label>
    575                         <input type="text" name="contact_form_website" value="'.$api_third['web'].'" id="contact_form_website">';
     644                        <input type="text" name="contact_form_website" value="'.$api_third['web'].'" id="contact_form_website" class="'.$tbl_class['class_contact_form_website'].'">';
    576645                    }
    577646                    if ($contact[0]->contact_form_note == 0) {
     647
     648                        if (isset($api_third['stickyNote']) && !empty($api_third['stickyNote'])) {
     649                            $contact_form_note = $api_third['stickyNote'];
     650                        } elseif (isset($api_contact['stickyNote']) && !empty($api_contact['stickyNote'])) {
     651                            $contact_form_note = $api_contact['stickyNote'];
     652                        } elseif (isset($api_opportunity['stickyNote']) && !empty($api_opportunity['stickyNote'])) {
     653                            $contact_form_note = $api_opportunity['stickyNote'];
     654                        } else {
     655                            $contact_form_note = "";
     656                        }
     657
    578658                        $render .= '
    579659                        <label>'.__('Message', PLUGIN_NOM_LANG).'</label>
    580                         <textarea name="contact_form_note" id="contact_form_note">'.$api_third['stickyNote'].'</textarea>';
    581                     }
     660                        <textarea name="contact_form_note" id="contact_form_note" class="'.$tbl_class['class_contact_form_note'].'">'.$contact_form_note.'</textarea>';
     661                    }
     662                   
     663                    // CUSTOM FIELD
     664                    // models
     665                    $t_contactForm  = new models\TContactForm();
     666                    $contact        = $t_contactForm->getContactForm($id);
     667                    $t_customFields = new models\TSellsyCustomFields();
     668                    $c_customFields = new SellsyCustomFieldsController();
     669
     670                    // init
     671                    $contact_form_custom_fields_value = json_decode($contact[0]->contact_form_custom_fields_value);
     672                    $cf = '';
     673
     674                    // cf all
     675                    foreach ($contact_form_custom_fields_value as $k=>$v) {
     676                        $cf = $t_customFields->getOne(array('id'=>$v));
     677                        if ($cf->response->status == 'ok') {
     678                            $render .= $c_customFields->getGenerator($cf->response, $tbl_class);
     679                        }
     680                    }
     681                   
     682                   
    582683
    583684                    // reCaptcha : cle du site
     
    588689                    ) {
    589690                        $render .= '
    590                             <div class="g-recaptcha" data-sitekey="'.$setting[0]->setting_recaptcha_key_website.'" '.$class_ticket_support_recaptcha.'></div>';
     691                        <div class="g-recaptcha" data-sitekey="'.$setting[0]->setting_recaptcha_key_website.'" '.$class_ticket_support_recaptcha.'></div>';
    591692                    }
    592693
  • eewee-sellsy/trunk/controllers/ToolsController.php

    r1582936 r1787929  
    5151        }
    5252
     53        /**
     54         * Get current url
     55         * @return string current url
     56         */
     57        public static function getUrl() {
     58            $url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
     59            $url .= ( $_SERVER["SERVER_PORT"] != 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
     60            $url .= $_SERVER["REQUEST_URI"];
     61            return $url;
     62        }
     63
     64        /**
     65         * Check string is json
     66         * @param $string
     67         * @return bool
     68         */
     69        public static function isJson($string){
     70            return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
     71        }
     72
    5373    }//fin class
    5474   
  • eewee-sellsy/trunk/css/style.css

    r1652294 r1787929  
    11/* BORDER */
    22.title1{ border-bottom:1px solid #333; text-align:left; text-transform:uppercase; padding-bottom:10px; margin:20px 0 10px 0; }
     3.border-error{ border:1px solid red; }
    34
    45/* MARGIN */
     
    3738.hndle{ padding: 10px; }
    3839.eewee-success{ border:1px solid green; }
    39 .eewee-error{ border:1px solid red; }
     40.eewee-error{ border:1px solid red !important; }
    4041.eewee-required{ color:red; }
    4142.eewee-success-message{ padding:10px; margin-top:5px; margin-bottom:5px; color:#468847; border:1px solid #468847; background-color:#dff0d8; text-transform:uppercase;
    4243    text-align:center; }
    43 .eewee-error-message{ padding:10px; margin-top:5px; margin-bottom:5px; color:#c76d6b; border:1px solid #c76d6b; background-color:#f2dede; text-transform:uppercase; text-align:center; }
     44.eewee-error-message{ padding:10px; margin-top:5px; margin-bottom:5px; color:#c76d6b; border:1px solid #c76d6b; background-color:#f2dede; text-transform:uppercase; }
     45.eewee-error-message li{ margin-left:1em; }
  • eewee-sellsy/trunk/forms/FContactFormEdit.php

    r1638551 r1787929  
    454454                            </tr>
    455455
     456
     457
     458
     459                            <?php
     460                            //------------------------------------------------------------------------------------------
     461                            // CUSTOM FIELDS
     462                            //------------------------------------------------------------------------------------------
     463                            ?>
     464                            <tr>
     465                                <th colspan="2">
     466                                    <div class="title1"><?php _e('Custom fields', PLUGIN_NOM_LANG); ?></div>
     467                                </th>
     468                            </tr>
     469                            <tr>
     470                                <th>
     471                                    <?php _e('Quantity custom fields', PLUGIN_NOM_LANG); ?> :
     472                                </th>
     473                                <td>
     474                                    <?php
     475                                    $qtyCf = 0;
     476                                    if (isset($r[0]->contact_form_custom_fields_quantity) && !empty(isset($r[0]->contact_form_custom_fields_quantity))) {
     477                                        $qtyCf = $r[0]->contact_form_custom_fields_quantity;
     478                                    }
     479                                    echo '<input type="text" name="contact_form_custom_fields_quantity" value="'.$qtyCf.'">';
     480                                    ?>
     481                                </td>
     482                            </tr>
     483                            <tr>
     484                                <th>
     485
     486                                </th>
     487                                <td>
     488                                    <?php
     489                                    // Model : get cf
     490                                    $t_customFields       = new models\TSellsyCustomFields();
     491                                    $responseCustomFields = $t_customFields->getCustomFields();
     492
     493                                    // Exist (cf in db)
     494                                    if (isset($r[0]->contact_form_custom_fields_value) && !empty($r[0]->contact_form_custom_fields_value)) {
     495                                        $cfVal = json_decode($r[0]->contact_form_custom_fields_value); // cfid
     496                                    } else {
     497                                        $cfVal = '';
     498                                    }
     499
     500                                    // CF Value
     501                                    foreach ($cfVal as $k=>$v) {
     502                                        $tbl_value[$k] = $v;
     503                                    }
     504
     505                                    // Form : select
     506                                    for ($i=0; $i<$qtyCf; $i++) {
     507                                        helpers\FormHelpers::getCustomFields(array(
     508                                            'echo'                  => true,
     509                                            'form_name'             => 'contact_form_custom_fields_value_'.$i,
     510                                            'form_value'            => $tbl_value[$i],          // cf all
     511                                            'responseCustomFields'  => $responseCustomFields,   // use for display cf all
     512                                            'useOn_x'               => $r[0]->contact_form_setting_add_what,
     513                                        ));
     514                                    }
     515                                    ?>
     516                                </td>
     517                            </tr>
     518
    456519                        </table>
    457520
  • eewee-sellsy/trunk/helpers/FormHelper.php

    r1582936 r1787929  
    11<?php
     2namespace fr\eewee\eewee_sellsy\models;
    23namespace fr\eewee\eewee_sellsy\helpers;
    34
     
    56
    67if( !class_exists('FormHelpers')){
    7     class FormHelpers {
     8    class FormHelpers
     9    {
    810
    911        /**
     12         * BACK (ADMIN)
     13         * Render form : custom fields
     14         * @param $d
     15         * @return mixed
     16         */
     17        public static function getCustomFields( $d )
     18        {
     19            if (!isset($d['form_name']) /*|| !isset($d['form_value'])*/ || !isset($d['responseCustomFields'])) { return false; }
     20
     21            // INIT
     22            $options                = array();
     23            $disabled               = 'disabled';
     24            $selected               = '';
     25            $isRequired             = '';
     26            $echo                   = $d['echo'];
     27            $form_name              = $d['form_name'];
     28            $form_value             = $d['form_value'];
     29            $resultsCustomFields    = $d['responseCustomFields']->response->result;
     30
     31            // CF ALL
     32            foreach ($resultsCustomFields as $resultCustomFields) {
     33
     34                if ($resultCustomFields->status == 'ok') {
     35
     36                    // only "simpletext" for the moment
     37                    if ($resultCustomFields->type == 'simpletext') {
     38                        $disabled = '';
     39                    } else {
     40                        $disabled = 'disabled';
     41                    }
     42
     43                    // required
     44                    if ($resultCustomFields->isRequired == 'Y') {
     45                        $isRequired = '*';
     46                    } else {
     47                        $isRequired = '';
     48                    }
     49
     50                    // selected
     51                    if ($form_value == $resultCustomFields->cfid) {
     52                        $selected = 'selected';
     53                    } else {
     54                        $selected = '';
     55                    }
     56
     57                    $options[] = '<option value="'.$resultCustomFields->cfid.'" '.$disabled.' '.$selected .'>'.$resultCustomFields->name.' ('.$resultCustomFields->type.') '.$isRequired.'</option>';
     58                }
     59            }
     60
     61            // SELECT
     62            $r = '
     63            <select name="'.$form_name.'">
     64                '.implode("", $options).'
     65            </select>
     66            <br>';
     67
     68            // RENDER
     69            if ($echo) {
     70                echo $r;
     71            } else {
     72                return $r;
     73            }
     74        }
     75
     76        /**
     77         * FRONT
     78         * Render form : custom fields
     79         * @param $id (cfid)
     80         * @return mixed
     81         */
     82        public static function getCustomFieldsFront( $id )
     83        {
     84
     85        }
     86
     87
     88            /**
    1089         * Render form : radio
    1190         * @param $d
     
    41120                return $r;
    42121            }
    43         }       
     122        }
    44123
    45124    }//fin class
  • eewee-sellsy/trunk/index.php

    r1652294 r1787929  
    44Plugin URI: http://www.eewee.fr
    55Description: Simple form for : add support ticket to Sellsy, add prospect to Sellsy.
    6 Version: 1.0.11
     6Version: 1.1
    77Author: Michael DUMONTET
    88Author URI: http://www.eewee.fr/wordpress/
     
    1616 * Definitions
    1717 *
    18  * @since 1.0.0
     18 * @since 1.0
    1919 */
    2020global $wpdb;
    21 define( 'EEWEE_VERSION', '1.0.11' );
     21define( 'EEWEE_VERSION', '1.1' );
    2222define( 'EEWEE_SELLSY_PLUGIN_DIR',      WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
    2323define( 'EEWEE_SELLSY_PLUGIN_URL',      WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) );
     
    2626define( 'EEWEE_SELLSY_DEBUG',           false);
    2727for( $i=1 ; $i<=3 ; $i++ ) {
    28     define( 'EEWEE_SELLSY_URL_SOUS_MENU_'.$i,      admin_url( 'admin.php?page=idSousMenu'.$i, 'http' ) );
     28    define( 'EEWEE_SELLSY_URL_SOUS_MENU_'.$i,      admin_url().'admin.php?page=idSousMenu'.$i);
    2929    define( 'EEWEE_SELLSY_URL_BACK_SOUS_MENU_'.$i, admin_url().'admin.php?page=idSousMenu'.$i);
    3030}
     
    3535 * Required CSS / JS
    3636 *
    37  * @since 1.0.0
     37 * @since 1.0
    3838 */
    3939function ajouterScriptsEeweeSellsy(){
     
    5757        }
    5858    }
     59    wp_enqueue_script( PLUGIN_NOM_LANG.'-js', plugins_url('eewee-sellsy/js/front.js'), array('jquery'));
    5960}
    6061add_action( 'init', 'ajouterScriptsEeweeSellsy' );
     
    6364 * Required Files
    6465 *
    65  * @since 1.0.0
     66 * @since 1.0
    6667 */
    6768// LIBS
     
    7879require_once ( EEWEE_SELLSY_PLUGIN_DIR . '/models/TSellsyStaffs.php' );
    7980require_once ( EEWEE_SELLSY_PLUGIN_DIR . '/models/TSellsyOpportunities.php' );
     81require_once ( EEWEE_SELLSY_PLUGIN_DIR . '/models/TSellsyCustomFields.php' );
     82require_once ( EEWEE_SELLSY_PLUGIN_DIR . '/models/TSellsyTracking.php' );
    8083
    8184// HELPERS
    8285require_once ( EEWEE_SELLSY_PLUGIN_DIR . '/helpers/FormHelper.php' );
     86require_once ( EEWEE_SELLSY_PLUGIN_DIR . '/helpers/dbUpdate.php' );
    8387
    8488// FORMS
     
    8993
    9094// CONTROLLERS
     95require_once( EEWEE_SELLSY_PLUGIN_DIR . '/controllers/CookieController.php' );
    9196require_once( EEWEE_SELLSY_PLUGIN_DIR . '/controllers/AjaxController.php' );
    9297require_once( EEWEE_SELLSY_PLUGIN_DIR . '/controllers/InstallController.php' );
     
    9499require_once( EEWEE_SELLSY_PLUGIN_DIR . '/controllers/ShortcodeController.php' );
    95100require_once( EEWEE_SELLSY_PLUGIN_DIR . '/controllers/AdminController.php' );
     101require_once( EEWEE_SELLSY_PLUGIN_DIR . '/controllers/SellsyCustomFieldsController.php' );
    96102
    97103use fr\eewee\eewee_sellsy\controllers;
    98 
    99104$s = new controllers\ShortcodeController();
    100105$a = new controllers\AjaxController();
    101106
     107// UPDATE DB
     108use fr\eewee\eewee_sellsy\helpers;
     109$dbUpdate = new helpers\DbUpdate();
     110$dbVersion = $dbUpdate->getVersion();
     111if (EEWEE_VERSION > $dbVersion) { $dbUpdate->updateDb($dbVersion); }
     112
    102113/**
    103  * Instantiate Classe
     114 * Instantiate Class
    104115 *
    105  * @since 1.0.0
     116 * @since 1.0
    106117 */
    107118$adminController = new controllers\AdminController();
     119
     120/**
     121 * Instantiate Class
     122 *
     123 * @since 1.0
     124 */
     125if (!is_admin()) {
     126    $cookieController = new controllers\CookieController();
     127    $cookieController->exec();
     128}
    108129
    109130/**
     
    114135 * @uses register_uninstall_hook()
    115136 *
    116  * @since 1.0.0
     137 * @since 1.0
    117138 */
    118139register_activation_hook( __FILE__, array( $adminController, 'eewee_activate' ) );
     
    125146 * @uses add_action()
    126147 *
    127  * @since 1.0.0
     148 * @since 1.0
    128149 */
    129150add_action( 'admin_menu', array( $adminController, 'eewee_adminMenu' ) );
  • eewee-sellsy/trunk/js/main.js

    r1610106 r1787929  
    6060        }
    6161    });
    62 */
     62    */
    6363
    6464});
  • eewee-sellsy/trunk/models/TContactForm.php

    r1638551 r1787929  
    7878            $contact_form_setting_opportunity_pipeline  = (int)$p['contact_form_setting_opportunity_pipeline'];
    7979            $contact_form_setting_opportunity_step      = (int)$p['contact_form_setting_opportunity_step'];
     80            $contact_form_custom_fields_quantity        = (int)$p['contact_form_custom_fields_quantity'];
     81            $contact_form_custom_fields_value           = array();
     82            for ($i=0; $i<$contact_form_custom_fields_quantity; $i++) {
     83                $contact_form_custom_fields_value[] = (int)$p['contact_form_custom_fields_value_'.$i];
     84            }
     85            $contact_form_custom_fields_value_json = json_encode($contact_form_custom_fields_value, JSON_FORCE_OBJECT);
    8086
    8187            $r = $wpdb->update(
     
    107113                    'contact_form_website'                      => $p['contact_form_website'],
    108114                    'contact_form_note'                         => $p['contact_form_note'],
    109                     'contact_form_status'                       => $p['form_status']
     115                    'contact_form_status'                       => $p['form_status'],
     116
     117                    'contact_form_custom_fields_quantity'       => $contact_form_custom_fields_quantity,
     118                    'contact_form_custom_fields_value'          => $contact_form_custom_fields_value_json,
    110119                ),
    111120                // WHERE (valeur)
     
    140149                    '%d',
    141150                    '%d',
     151
     152                    '%d',
     153                    '%s'
    142154                ),
    143155                // WHERE (type)
  • eewee-sellsy/trunk/readme.md

    r1636317 r1787929  
    442. Add a contact form shortcode (Wordpress > Sellsy prospect).
    553. Add a contact form shortcode (Wordpress > Sellsy prospect and opportunity).
     64. Tracking page views
     75. You can use the Sellsy custom fields
    68
    79Form with captcha
  • eewee-sellsy/trunk/readme.txt

    r1652294 r1787929  
    1515Create a multitude of forms for managing your support tickets. The form contains the following fields: Subject, E-mail, Name and Message.
    1616
    17 = Generate simple form (add prospect in Sellsy) =
    18 Create a multitude of forms to manage your prospecting. The validation of the form will create a prospect on Sellsy and optionally an opportunity.
     17= Generate simple form (add prospect/opportunity in Sellsy) =
     18Create a multitude of forms to manage your prospecting.
     19The validation of the form will create a prospect on Sellsy and optionally an opportunity.
     20(You can use the Sellsy custom fields, such as "simple text", ...)
     21
     22= Tracking =
     23Saves the different pages visited by your prospect.
     24Then when validating the prospecting / opportunity form, you can view these pages on Sellsy.
    1925
    2026* Question : [eewee.fr](http://www.eewee.fr).
     
    4753
    4854== Changelog ==
     55
     56= 1.1 =
     57* Create table version and update version auto
     58
     59= 1.0.14 =
     60* Add CF SimpleText
     61
     62= 1.0.13 =
     63* Add tracking
     64
     65= 1.0.12 =
     66* Url http / https
    4967
    5068= 1.0.11 =
  • eewee-sellsy/trunk/uninstall.php

    r1610848 r1787929  
    66
    77global $wpdb;
     8$sql[] = "DROP TABLE  `".$wpdb->prefix."eewee_sellsy_version`";
    89$sql[] = "DROP TABLE  `".$wpdb->prefix."eewee_sellsy_setting`";
    910$sql[] = "DROP TABLE  `".$wpdb->prefix."eewee_sellsy_ticket`";
  • eewee-sellsy/trunk/view/contactFormEdit.php

    r1636317 r1787929  
    4343        $contact_form_setting_opportunity_pipeline  = (int)$_POST['contact_form_setting_opportunity_pipeline'];
    4444        $contact_form_setting_opportunity_step      = (int)$_POST['contact_form_setting_opportunity_step'];
     45        $contact_form_custom_fields_quantity        = (int)$_POST['contact_form_custom_fields_quantity'];
    4546        if (empty($contact_form_setting_opportunity_source)) { unset($_POST['contact_form_setting_opportunity_source']); }
    4647        if (empty($contact_form_setting_opportunity_pipeline)) { unset($_POST['contact_form_setting_opportunity_pipeline']); }
    4748        if (empty($contact_form_setting_opportunity_step)) { unset($_POST['contact_form_setting_opportunity_step']); }
     49        if (empty($contact_form_custom_fields_quantity)) { unset($_POST['contact_form_custom_fields_quantity']); }
    4850
    4951        // UPDATE
Note: See TracChangeset for help on using the changeset viewer.